Application Development and Automation 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: 
Read only

merging internal tables

Former Member
0 Likes
399

Hi,

if i have two internal tables itab1, itab2 and if i want to append itab1 to itab2 what would be the best approach.

your help would be appreciated.

Thanks,

kranthi.

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
331

Hi,

If ITAB1 and ITAB2 are of same structure,then you can use

<b>Append lines of itab1 to itab2.</b>

If the strutures are different,then

loop at itab1 into wa1.

move-corresponding wa1 to wa2.

append wa2 to itab2.

endloop.

Kindly reward points,if it is useful.Otherwise,get back.

2 REPLIES 2
Read only

sridevi_p
Active Contributor
0 Likes
331

Hi,

Check the following code -

REPORT ZSRI_MERGE_ITAB .

data: begin of itab1 occurs 0 ,

lifnr like lfa1-lifnr ,

land1 like lfa1-land1 ,

name1 like lfa1-name1 ,

end of itab1 .

data: begin of itab2 occurs 0 ,

lifnr like lfa1-lifnr ,

land1 like lfa1-land1 ,

name1 like lfa1-name1 ,

end of itab2 .

select lifnr land1 name1

from lfa1 into itab1 up to 2 rows .

append itab1.

endselect.

select lifnr land1 name1

from lfa1 into itab2 up to 3 rows.

append itab2.

endselect.

.

loop at itab1.

write: / itab1.

endloop.

write: / 'ITAB2'.

loop at itab2.

write: / itab2.

endloop.

write: / 'After appending'.

append lines of itab1 to itab2.

write: / 'ITAB2'.

loop at itab2.

write: / itab2.

endloop.

APPEND LINE OF... --> this will help u

Revert in case of any issues, else reward points.

Regards

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
332

Hi,

If ITAB1 and ITAB2 are of same structure,then you can use

<b>Append lines of itab1 to itab2.</b>

If the strutures are different,then

loop at itab1 into wa1.

move-corresponding wa1 to wa2.

append wa2 to itab2.

endloop.

Kindly reward points,if it is useful.Otherwise,get back.