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

Internal Table

Former Member
0 Likes
584

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
Read only

former_member194669
Active Contributor
0 Likes
563

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.

a®

5 REPLIES 5
Read only

SAPAI
Participant
0 Likes
563

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

Read only

Former Member
0 Likes
563

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

Read only

former_member194669
Active Contributor
0 Likes
564

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.

a®

Read only

Former Member
0 Likes
563

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.

Read only

Former Member
0 Likes
563

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