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 of internal tables

Former Member
0 Kudos

hi all,

how we can copy internal table itab1 into internal table itab2

itab1 having 2 fileds and itab2 having 3 fields.

now, i want an internal tbale who is having 5 filds i.e 2 fields of itab1 and 3 fields of itab2

so, we clubed these fileds into an internal table.

1 ACCEPTED SOLUTION

former_member184619
Active Contributor
0 Kudos

Hi Vipin,

Check this ex:

ITAB1 is having fields "A","B", "C".

ITAB2 is having fields "A","D", "E".

Create i_final internal table to have all fields of 2 internal tables.

i_final is having "A","B","C","D","E".

SORT itab1 ,itab2 by A

LOOP AT ITAB1.

READ TABLE itab2 WITH KEY a = itab1-a BINARY

SEARCH.

IF SY-SUBRC EQ 0.

MOVE : itab1-a TO i_final-a,

itab1-b TO i_final-b,

itab1-c TO i_final-c,

itab2-d TO i_final-d,

itab2-e TO i_final-e.

APPEND i_final.

ENDIF.

ENDLOOP.

3 REPLIES 3

Former Member
0 Kudos

move-corresponding fields of itab1 to itab2.

Former Member
0 Kudos

Hi,

declare work areas of the internal table types and read the internal table data in to work areas usin read statement or loop ..endloop stament and then move the the corresponding fields between the work areas and then append the work areas to their corresponding internal tables.

former_member184619
Active Contributor
0 Kudos

Hi Vipin,

Check this ex:

ITAB1 is having fields "A","B", "C".

ITAB2 is having fields "A","D", "E".

Create i_final internal table to have all fields of 2 internal tables.

i_final is having "A","B","C","D","E".

SORT itab1 ,itab2 by A

LOOP AT ITAB1.

READ TABLE itab2 WITH KEY a = itab1-a BINARY

SEARCH.

IF SY-SUBRC EQ 0.

MOVE : itab1-a TO i_final-a,

itab1-b TO i_final-b,

itab1-c TO i_final-c,

itab2-d TO i_final-d,

itab2-e TO i_final-e.

APPEND i_final.

ENDIF.

ENDLOOP.