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 itab1 to itab2 if some fields afre different

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

REFRESH: itab2.
LOOP AT itab1.
  MOVE-CORRESPONDING itab1 TO itab2.
  APPEND itab2.
ENDLOOP.

Regards

Tamá

6 REPLIES 6

former_member196079
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi!

REFRESH: itab2.
LOOP AT itab1.
  MOVE-CORRESPONDING itab1 TO itab2.
  APPEND itab2.
ENDLOOP.

Regards

Tamá

former_member233090
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Use move-corresponding.

Regards

Vinod

Former Member
0 Kudos

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.