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

Combining two internal tables

Former Member
0 Likes
921

Hi any body plz send me the code for combining two internal tables( ITAB_vbap and ITAB_vbkd) and filling the final data to final one internal table(ITAB_final)

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
896

Sort itab_vbap by vbeln posnr.

sort itab_vbkd by vbeln posnr.

Loop at itab_vbap into wa_vbap.

read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.

if sy-subrc = 0.

move corresponding wa_vbap to wa_final.

move corresponding wa_vbkd to wa_final.

append wa_final to itab_final.

endif.

endloop.

For move corresponding statement the name of the fields should match in both the work areas.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Sort itab_vbap by vbeln posnr.

sort itab_vbkd by vbeln posnr.

Loop at itab_vbap into wa_vbap.

read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.

if sy-subrc = 0.

move corresponding wa_vbap to wa_final.

move corresponding wa_vbkd to wa_final.

append wa_final to itab_final.

endif.

endloop.

For move corresponding statement the name of the fields should match in both the work areas.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

6 REPLIES 6
Read only

Former Member
0 Likes
897

Sort itab_vbap by vbeln posnr.

sort itab_vbkd by vbeln posnr.

Loop at itab_vbap into wa_vbap.

read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.

if sy-subrc = 0.

move corresponding wa_vbap to wa_final.

move corresponding wa_vbkd to wa_final.

append wa_final to itab_final.

endif.

endloop.

For move corresponding statement the name of the fields should match in both the work areas.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

0 Likes
896

Thanks for ur code , its really helpfull.

BALU

Read only

Former Member
0 Likes
896

Hi,

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.

Regards,

Laxmi.

Read only

0 Likes
896

Gud code thanks

Read only

0 Likes
896

HI,

If tables are of the same type, try this

INSERT LINES OF itab1 INTO TABLE itab3.
INSERT LINES OF itab2 INTO TABLE itab3.

Regards,

Joris Bots

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
896

Hi,

loop at itab_vbap into wa_vbap.

move-corresponding wa_vbap to wa_final.

loop at itab_vbkd into wa_vbkd where vbeln = wa_vbap and posnr = wa_posnr.

move-corresponding wa_vbkd to wa_final.

append wa_final to itab_final.

endloop.

endloop.