Application Development 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: 

Internal Table

Former Member
0 Kudos

Hi Experts,

I have two internal tables with different structures.

In My first internal table have fields like,

EMP_ID, EMP_NAME, EMP_CITY, EMP_COUNTRY.

But In my Second Internal have the Structure like,

EMP_ID, EMP_NAME,

So Based on First Internal table's EMP_ID I need to get the EMP-NAME to my second Internal Table.

How Can I do This? Help me on this isssue.

Thanks in Advance,

Points Assured.

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Hi,


sort itab2 by emp_id.
data : v_tabix like sy-tabix.
loop at itab1.
  v_tabix = sy-tabix.
  read table itab2 with key emp_id = itab1-emp_id
                                       binary search.
  if sy-subrc eq 0.
     move itab2-emp_name to itab1-emp_name.
     modify itab1 index v_tabix.  
  endif.
endloop.

5 REPLIES 5

SAPAI
Participant
0 Kudos

Loop at the first internal table and read the second one based on the KEY EMP_ID.

Former Member
0 Kudos

Hi,

Here is pseudo logic,

SORT ITAB1 BY ID.

SORT ITAB2 BY ID.

LOOP AT ITAB2.

READ TABLE ITAB1 WITH KEY ID = ITAB2-ID.

IF SY-SUBRC EQ 0.

ITAB2-NAME = ITAB1-NAME.

MODIFY ITAB2 INDEX SY-TABIX TRANSPORTING NAME.

ENDIF.

ENDLOOP.

Hope this helps.

ashish

former_member194669
Active Contributor
0 Kudos

Hi,


sort itab2 by emp_id.
data : v_tabix like sy-tabix.
loop at itab1.
  v_tabix = sy-tabix.
  read table itab2 with key emp_id = itab1-emp_id
                                       binary search.
  if sy-subrc eq 0.
     move itab2-emp_name to itab1-emp_name.
     modify itab1 index v_tabix.  
  endif.
endloop.

Former Member
0 Kudos

LOOP at itab2.

read table itab1 with key emp_id = itab2-emp_id.

itab2-emp_name = itab1-emp_name.

MODIFY itab2 INDEX sy-tabix.

ENDif.

Former Member
0 Kudos

Hi

fill the first one with data and read that with that key EMP_ID and fill the 2nd one.

loop at ITAB1.

read table itab2 with key emp_id = itab1-emp_id.

itab2-name = itab1-name.

append itab2.

clear itab2.

endloop.

Regards

Anji