Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

assign data

Former Member
0 Kudos

Hi...

internal table new field what step and create assign the new data, it's possible.

plz explain.

regards,

S.HARI

2 REPLIES 2

Former Member
0 Kudos

Hi Hariharalingam,

Your requirement is to add one more field in an internal table and populate it ..right?

first check your data declaration

assume int_table is your internal table

if internal table declaration is

(01) data : int_table type table of TABLE.

where table is a ztable or standard table..then if the field is already present in the TABLE in se11,it is already present in your internal table..you just need to fill it

if it is a field ot there in the TABLE you need to create as mentioned in the next step

(02) data: int_table type table of XXX.

imagine you have a declaration

types\data : begin of XXX,

abc type ab-abc,

end of XXX.

then to add field to internal table

add field in the types declaration

types\data : begin of XXX,

abc type ab-abc,

newfield type ab-newfield,

end of XXX.

Filling data:

based on your requirement fetch data from table or user..and store it to a workarea

use modify statement to update your internal table like

modify table int_table from workarea transporting newfield.

This will update only the the field "newfield"..no other fields will be updated..

Regards

Byju

Former Member
0 Kudos

Hi,

Suppose , if you want to add new field value in internal table then you need to append the fields value after looping .This is the procedure for ADDING FIELdS IN TO INTERNAL TABLE. just copy n paste in se38 editor and run the program

*----


  • STRUCTURE DECLARATION

*----


TYPES : BEGIN OF ST_VBAP,

VBELN TYPE VBAP-VBELN,

POSNR TYPE VBAP-POSNR,

MATNR TYPE VBAP-MATNR,

END OF ST_VBAP.

*----


  • INTERNAL DECLARATION

*----


DATA : IT_VBAP TYPE STANDARD TABLE OF ST_VBAP WITH HEADER LINE.

WRITE : 'BEFORE APPENDING' COLOR COL_BACKGROUND.

SKIP 2.

ULINE.

SKIP 2.

SELECT VBELN

POSNR

MATNR

FROM VBAP UP TO 5 ROWS

INTO TABLE IT_VBAP.

IF SY-SUBRC <> 0.

MESSAGE 'NO DATA FOUND' TYPE 'E'.

ENDIF.

*----BEFORE APPENDING--


WRITE : /5 'Sales Document' COLOR COL_HEADING,

20 'Sales Document Item' COLOR COL_HEADING,

40 'Material Number' COLOR COL_HEADING.

LOOP AT IT_VBAP.

WRITE : / IT_VBAP-VBELN,

20 IT_VBAP-POSNR,

50 IT_VBAP-MATNR.

ENDLOOP.

ULINE.

*--NEW DATA TO BE APPENDED--

IT_VBAP-VBELN = 'KF'.

IT_VBAP-POSNR = '007'.

IT_VBAP-MATNR = '1000'.

APPEND IT_VBAP.*----AFTER APPENDING-----

WRITE : / 'AFTER APPENDING' COLOR COL_BACKGROUND.

LOOP AT IT_VBAP.

WRITE : / IT_VBAP-VBELN,

20 IT_VBAP-POSNR,

50 IT_VBAP-MATNR.

ENDLOOP.

ENDFORM. " append_tab

Reward points if usefull

regards

Fareedas