04-14-2010 8:51 AM
Hello
What is the best way to move data from table itab1 to table itab2.
Both tables are the standard tables of the following structures :
itab1 itab2
F1 F2 F3 F4 F1 F2 F5 F6
I know loop into but hope there is more sphisticated way to do it
Thanks
04-14-2010 8:58 AM
Hi!
REFRESH: itab2.
LOOP AT itab1.
MOVE-CORRESPONDING itab1 TO itab2.
APPEND itab2.
ENDLOOP.
Regards
Tamá
04-14-2010 8:56 AM
HI
if the tables are of the same type just do this
tab2[] = tab2[].
or
MOVE-CORRESPONDING itab1 TO itab2.
else if the name of fields are different you must use
loop at lt_tab1 into ls_str1.
ls_str2-f1 = ls_str1-f1.
appens ls_str2 to lt_itab2.
endloop.
regards
Marco
04-14-2010 8:57 AM
see f1 help for MOVE.
---
MOVE-CORRESPONDING struc1 TO struc2.
All components with the same name are searched for in struc1 and struc2 and the content of components in struc1 is assigned to the components with the same name in struc2. All other components are not affected.
Regards,
Sumit
04-14-2010 8:58 AM
Hi!
REFRESH: itab2.
LOOP AT itab1.
MOVE-CORRESPONDING itab1 TO itab2.
APPEND itab2.
ENDLOOP.
Regards
Tamá
04-14-2010 9:01 AM
Hi,
you can move them using move-corresponding since both are of same type..
LOOP AT itab1.
MOVE-CORRESPONDING itab1 TO itab2.
APPEND itab2.
ENDLOOP.
cheers bhavana
04-14-2010 9:05 AM
04-14-2010 9:50 AM
Hi,
Use the following code
loop at itab1 into fs_itab1.
move fs_itab1-f1 to fs_itab2-f1.
move fs_itab1-f2 to fs_itab2-f2.
append fs_itab2 to itab2.
endloop.
It is recomended to move field wise than 'move corresponding' when there are many fields
as per performence wise.
Regards and Best wishes.