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

two internal table data move to third internal table

Former Member
0 Likes
2,135

i want to two internal table data into third internal table.

itab 1: l_t_lipso2_1 field : adqntp

itab 2: l_t_lipso2_2 field : adqntp

o/p itab 3: l_t_lipso2_3 fields : adqntp1, adqntp2.

actually itabl fields fetched different condition wise and itab2 fields fetched different condition.

i want to show my o/p itab3, as the two table datas as same row wise.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,013

As I can understand from your requirement the below soln should help.

Loop at itab1.

move itab1-adqntp to itab3-adqntp1.

read table itab2 index sy-tabix.

if sy-subrc = 0.

move itab2-adqntp to itab3-adqntp2.

append itab3.

endloop.

describe table itab1 lines l1.

describe table itab2 lines l2.

if l2 > l1.

l1 = l1 + 1.

loop at itab2 from l1 to l2.

move space to itab3-adqntp1.

move itab2-adqntp to itab3-adqnpt2.

append itab3.

endloop.

endif.

6 REPLIES 6
Read only

Former Member
0 Likes
1,013

Dear Santhosh,

PLease expalin the scenario in a little bit detail..like wether the 2 itabs contain records with same key or how they are related etc..

it seems to be more explanatory when u r posting some queries.

Regards

Sandeep

Read only

Former Member
0 Likes
1,013

hi,

do u have any common field in both the internal tables itab1 and itab2

Read only

Former Member
0 Likes
1,013

assuming that both the tables contain same fields and all the three tables have same structure:

loop at itab1 into wa_itab1.

append wa_itab1 to itab3

endloop.

loop at itab2 into wa_itab2.

append wa_itab2 to itab3

endloop.

Read only

Former Member
0 Likes
1,014

As I can understand from your requirement the below soln should help.

Loop at itab1.

move itab1-adqntp to itab3-adqntp1.

read table itab2 index sy-tabix.

if sy-subrc = 0.

move itab2-adqntp to itab3-adqntp2.

append itab3.

endloop.

describe table itab1 lines l1.

describe table itab2 lines l2.

if l2 > l1.

l1 = l1 + 1.

loop at itab2 from l1 to l2.

move space to itab3-adqntp1.

move itab2-adqntp to itab3-adqnpt2.

append itab3.

endloop.

endif.

Read only

Former Member
0 Likes
1,013

Hi

Try the following code this is working for me fine.

Tables: lfa1.

Data: begin of itab1 occurs 0,

land1 like lfa1-land1,

end of itab1,

begin of itab2 occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

end of itab2,

begin of itab3 occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

land1 like lfa1-land1,

end of itab3.

select land1 from lfa1 into table itab1 where land1 = 'IN'.

select lifnr name1 from lfa1 into table itab2 where name1 = 'Rajesh'.

loop at itab1.

write:/ itab1-land1.

endloop.

uline.

loop at itab2.

write:/ itab2-lifnr,itab2-name1.

endloop.

loop at itab1.

move itab1 to itab3.

append itab3.

endloop.

loop at itab2.

move itab2 to itab3.

append itab3.

endloop.

uline.

loop at itab3.

write:/ itab3-lifnr,itab3-name1,itab3-land1.

endloop.

Read only

Former Member
0 Likes
1,013

i got solution thanks