10-24-2007 3:56 PM
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.
10-24-2007 4:02 PM
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®
10-24-2007 4:00 PM
Loop at the first internal table and read the second one based on the KEY EMP_ID.
10-24-2007 4:01 PM
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
10-24-2007 4:02 PM
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®
10-24-2007 4:04 PM
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.
10-24-2007 4:07 PM
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