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: 

Copy the content among two internal tables

Former Member
0 Kudos

Hi Experts,

I have a query regarding internal table copy.

it may look silly, but could nt get the solution in single or two lines of code.

my query is:

I have two internal tables, which is having differnt structure, but over all, the fields are same, the order is different, how can I copy one table to another in one or two lines of code.

I can do it by looping one internal table and move every field to the destination, but I dont want to go for it, I want one or 2 lines of code to achive this functionality.

Pls advice.

Regards,

SR

5 REPLIES 5

Former Member
0 Kudos

Hi,

It is not possible in one line / two lines to move from one internal table to another if the structures are different.

As you mentioned it can be done by LOOP..ENDLOOP.

Thanks

Naren

Former Member
0 Kudos

Hi ,

Loop at itab1 into wa1.

move-corresponding wa1 to wa2.

append wa2 to itab2.

endloop.

Thanks,

Rajinikanth

Former Member
0 Kudos

appending lines of itab from 1 to 20 to itab .

Former Member
0 Kudos

try this ...

Loop at itab1.

move-corresponding itab1 to itab2.

append itab2.

endloop.

Former Member
0 Kudos

Hi,

you have to do a LOOP, but with the MOVE-CORRESPONDING statement there are not so much line of code required.


DATA ls_dest TYPE ZS_DEST.
DATA lt_dest TYPE TABLE OF ZS_DEST.
DATA lt_source TYPE TABLE OF ZS_SOURCE.
FIELD-SYMBOLS <ls_source> TYPE ZS_SOURCE.

LOOP AT LT_SOURCE ASSIGNING <ls_source>.
  MOVE-CORRESPONDING <ls_source> TO ls_dest.
  APPEND ls_dest TO lt_dest.
ENDLOOP.

Regards Rudi