06-18-2008 4:35 PM
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
06-18-2008 4:37 PM
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
06-18-2008 4:38 PM
Hi ,
Loop at itab1 into wa1.
move-corresponding wa1 to wa2.
append wa2 to itab2.
endloop.
Thanks,
Rajinikanth
06-18-2008 4:39 PM
06-18-2008 4:39 PM
try this ...
Loop at itab1.
move-corresponding itab1 to itab2.
append itab2.
endloop.
06-18-2008 4:42 PM
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