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: 

Move data from three internal table into another internal table

Former Member
0 Kudos

hai all ,

I have three internal tables , How can i move these three internal tables data into another internal table.

thanks regards

aumprakash

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

You can use the APPEND command.

... LINES OF jtab [FROM idx1] [TO idx2]

Effect

The rows of an internal table jtab are appended according to the same rules that apply for appending a workarea, in the sequence in which they exist in jtab. If jtab is an index table, you can restrict the rows to be appended by specifying FROM idx1 and TO idx2. In this case, only the table rows starting at table index idx1 or ending at table index idx2 from jtab are appended. For idx1 and idx2, data objects of type i are expected. If the value idx1 or idx2 is less than 0, an untreatable exception occurs. If idx1 is greater than idx2 or greater than the number of table rows, no rows are appended. If idx2 is greater than the number of table rows, it is set to the number of table rows.

Regards.

6 REPLIES 6

Former Member
0 Kudos

loop at itab1.

read table itab2 with key <field> = itab1-<field>.

if sy-subrc = 0.

move data to itab4 from itab2.

endif.

read table itab3 with key <field> = itab1-<field>.

if sy-subrc = 0.

move data to itab4 from itab3.

endif.

move data to itab4 from itab1.

append itab4.

endloop.

Former Member
0 Kudos

Hello,

You can use the APPEND command.

... LINES OF jtab [FROM idx1] [TO idx2]

Effect

The rows of an internal table jtab are appended according to the same rules that apply for appending a workarea, in the sequence in which they exist in jtab. If jtab is an index table, you can restrict the rows to be appended by specifying FROM idx1 and TO idx2. In this case, only the table rows starting at table index idx1 or ending at table index idx2 from jtab are appended. For idx1 and idx2, data objects of type i are expected. If the value idx1 or idx2 is less than 0, an untreatable exception occurs. If idx1 is greater than idx2 or greater than the number of table rows, no rows are appended. If idx2 is greater than the number of table rows, it is set to the number of table rows.

Regards.

Former Member
0 Kudos

Hi,

Check the code below.

LOOP AT it_ekko INTO wa_ekko.

READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_ekko-ebeln.

IF sy-subrc EQ 0.

READ TABLE it_ekkn INTO wa_ekkn WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp.

IF sy-subrc EQ 0.

READ TABLE it_eket INTO wa_eket WITH KEY ebeln = wa_ekkn-ebeln ebelp = wa_ekkn-ebelp etenr = wa_ekkn-veten.

IF sy-subrc EQ 0.

wa_final-ebeln = wa_ekko-ebeln.

wa_final-date = wa_ekko-date.

wa_final-ebelp = wa_ekpo-ebelp.

wa_final-matnr = wa_ekpo-matnr.

wa_final-menge = wa_ekpo-menge.

wa_final-meins = wa_ekpo-meins.

wa_final-eindt = wa_eket-eindt.

wa_final-netpr = wa_ekpo-netpr.

wa_final-werks = wa_ekpo-werks.

wa_final-bukrs = wa_ekko-bukrs.

wa_final-zekkn = wa_ekkn-zekkn.

APPEND wa_final TO it_final.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

Regards,

Rama.

Former Member
0 Kudos

Hi .,

It depends on the requirement .,

if you some common key fieds ,

loop on first table read second based on common field and is key field in the second table , if it is not a key field ( there will be multiple records with the field value ) use again loop on the second table with where condition .

Simmilarly you can get data from the third and create single record and append to combined table .

loop at itab .

Read table Jtab with key f1 = Itab-f1 ( if there is single record )

or

loop at jtab where f1= itab-f1 . ( Multiple records )

Read table Ktab with key F2 = itab-f2

or

loop at ktab where f2= itab-f2 . ( Multiple records )

create ltab with itab,jtab,ktab .

append ltab .

thanks

Sreenivas Reddy

Former Member
0 Kudos

HI,

You can use APPEND LINES ... to do that.Take one table as base table and append the lines of the second & third tables into the first table.

Best of luck,

Bhumika

Former Member
0 Kudos

Hi all thank very much i have got answer.