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

appending two internal tables

Former Member
0 Likes
3,489

hi friends,

i met with a situation, where i have to join 3 tables using the common fields using inner join.

i wrote 2 select statements and added contents to two different internal tables.

F

hi friends,

i met with a situation, where i have to join 3 tables using the common fields using inner join.

i wrote 2 select statements and added contents to two different internal tables.

F

4 REPLIES 4
Read only

former_member156446
Active Contributor
0 Likes
930

I dint find a question in ur post..

but if you are looking to append that two internal table.. if the structures are same then say

> append lines of itab1 to itab2 ( structure of both need to be >same)

Read only

RoySayak
Active Participant
0 Likes
930

loop at one internal table and append it to the other.

or use INTO APPENDING TABLE T_XXXX in the second select statement.

Thnaks

Sayak

Read only

former_member194669
Active Contributor
0 Likes
930

if 2 internal fields are same then


appending lines of i_tab1 to i_tab2.


if fields are not same


loop at i_tab1
  v_tabix = sy-tabix.
  read table i_tab3 with key <key fields of i_tab1>
  if sy-subrc eq 0.
    move corresponding fields i_tab1 to i_tab3.
    modify i_tab3 index v_tabix..
  else.
    move corresponding fields i_tab1 to i_tab3.
    append i_tab3.    
 endif.
endloop.

loop at i_tab2
  v_tabix = sy-tabix.
  read table i_tab3 with key <key fields of i_tab2>
  if sy-subrc eq 0.
    move corresponding fields i_tab2 to i_tab3.
    modify i_tab3 index v_tabix..
  else.
    move corresponding fields i_tab2 to i_tab3.
    append i_tab3.    
 endif.
endloop.

After this I_tab3 cotnains the combined results of i_tab1 & I_tab2

Read only

Former Member
0 Likes
930

Thanks for your suggestions. i have reached the solution.