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 fields from one table to another

Former Member
0 Kudos

Hi,

I would like to move fields from one internal table into corresponding fields of another internal table.

move-corresponding syntax seems only to work with structures. How do you accomplish this for internal tables? Do I have to use for loops?

regards

Baran

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

Hi baran,

yes u have to use the loop.

say one internal table is itab and the other is itab1

also workarea are wa_tab,wa_tab1 respectively.

Loop at itab into wa_tab.

move-corresponding wa_tab to wa_tab1.

append itab1 from wa_tab1.

clear : wa_tab,

wa_tab1.

Endloop.

regards,

Nagaraj

4 REPLIES 4

Former Member
0 Kudos

Loop at itab into wstab.

move-corresponding wstab to newtab.

append itab1 from newtab.

Endloop.

former_member404244
Active Contributor
0 Kudos

Hi baran,

yes u have to use the loop.

say one internal table is itab and the other is itab1

also workarea are wa_tab,wa_tab1 respectively.

Loop at itab into wa_tab.

move-corresponding wa_tab to wa_tab1.

append itab1 from wa_tab1.

clear : wa_tab,

wa_tab1.

Endloop.

regards,

Nagaraj

Former Member
0 Kudos

loop at itab.

move corresponding fields of itab to itab1.

append itab1.

clear itab1.

endloop.

former_member181962
Active Contributor
0 Kudos

Yes you have to use loops and move-correspoding statements unless you have all the common fields in the same order on both internal table and no different fields to the left most.

eg:

data: begin of itab1 occurs 0,

field1 type i,

end of itab1.

data: begin of itab2 occurs 0,

field1 type i,

field2(1),

end of itab2.

do 5 times.

itab1-field1 = sy-index.

append itab1.

enddo.

itab2[] = itab1[].

loop at itab2.

write:/ itab2-field1.

endloop.

The above code would give you some idea.

Regards,

ravi