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

passing int tab

Former Member
0 Likes
718

how to transfer the data from two internal tables into another internal table?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
692

Hi,

Let us have there are three tables ITAB1, ITAB2 AND ITAB3.

The contents of ITAB1 & ITAB2 to be transfered to ITAB3.

APPEND LINES OF ITAB1 TO ITAB3.

APPEND LINES OF ITAB2 TO ITAB3.

Regards,

Irfan Hussain

Note: If useful , Please award the sutiable points,

6 REPLIES 6
Read only

dani_mn
Active Contributor
0 Likes
692

HI,

LOOP AT itab1.

READ TABLE itab2 WITH KEY field = itab1-field.

IF sy-subrc = 0.

itab3-field = itab1-field.

itab3-field1 = itab2-field1.

itab3-field2 = itab2-field2.

APPEN itab3.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
692
Loop at itab1 into wa1.
read table itab2 into wa2 with key f1 = wa1-f1 
                                   f2 = wa1-fa2.
if sy-subrc eq 0.
move-corresponding wa1 to wa3.
move-corresponding wa2 to wa3.
append wa3 to itab3.
endif.
endloop.

null

Read only

former_member283648
Participant
0 Likes
692

Hi,

1. If the two internal tables have the same structure as the one to which u want to pass then u can use the command.

APPEND LINES OF ITAB1 TO ITAB3.

APPEND LINES OF ITAB2 TO ITAB3.

2. If the two internal tables have same key fields then u can do a nested loop like this.

Loop at itab1.

loop at itab2 where <Mention the matching key fields>

populate the work area of ITAB3.

APPEND WA TO ITAB3.

ENDLOOP.

ENDLOOP.

Read only

Former Member
0 Likes
692

Hi,

if the three tables having the same structures then you can use

itab1 = itab2

and then append lines of itab3 to itab2.

if three are having different structures then

loop at itab1.

move the fields to work area of itab3.

append work area to itab3.

endloop.

and do then same itab2,

Read only

Former Member
0 Likes
692

Hi Sunil,

Loop at one internal Table and Move-corresponding Fields of the First internal Table to the Final Internal table. With in the loop REad the second internal Table with key XXXXXXX = final-XXXXXXX. and move that particular fields from second internal table into final internal table.

Bye

Murthy

Read only

Former Member
0 Likes
693

Hi,

Let us have there are three tables ITAB1, ITAB2 AND ITAB3.

The contents of ITAB1 & ITAB2 to be transfered to ITAB3.

APPEND LINES OF ITAB1 TO ITAB3.

APPEND LINES OF ITAB2 TO ITAB3.

Regards,

Irfan Hussain

Note: If useful , Please award the sutiable points,