‎2010 Apr 26 12:11 PM
Hi All,
I have 2 internal table. I need STLNR value to another internal table. Both having same field. But while reading from one internal table to another internal table using IDNRK key, One idnrk having 2 different stlnr value. But its taking only one. How to take both the values?
The internal table value like below.
it_stpo--> This is first table, Here one Idnrk having different stlnr value. I need the same in to next table. Here i read with idnrk field but its taking one stlnr value only into next table.
How to change the logic ?
Below is it_stpo table and next one is it_mbew_1
it_stpo
STLNR IDNRK MENGE
17224 00439RM1 2.3
17225 00439RM1 4.2
172333 00849RM2 5.6
172158 00432TM3 7.2
152164 00583RM4 8.4
176123 00583RM4 2.3
it_mbew_1
STLNR IDNRK STPRS
00439RM1 111.22
00439RM1 126.45
00849RM2 3.3364
00432TM3 15.5888
00583RM4 0
00583RM4 0.235
My logic like below,
SORT it_stpo BY idnrk.
SORT it_mbew_1 BY matnr.
LOOP AT it_mbew_1 INTO wa_mbew_1.
READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr BINARY SEARCH.
IF sy-subrc = 0.
wa_mbew_1-stlnr = wa_stpo-stlnr.
MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
ENDIF.
ENDLOOP.
Kindly help us.
Mohana
‎2010 Apr 26 12:22 PM
Hello,
Try something like this,
SORT it_stpo BY idnrk.
SORT it_mbew_1 BY matnr.
LOOP AT it_mbew_1 INTO wa_mbew_1.
LOOP AT it_stpo INTO wa_stpo where idnrk = wa_mbew_1-matnr.
if sy-tabix > 1.
exit.
else.
wa_mbew_1-stlnr = wa_stpo-stlnr.
MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
ENDIF.
ENDLOOP.
ENDLOOP.
Vikranth
‎2010 Apr 26 12:32 PM
Try below logic.
add one more field to it_stpo flag type char01.
update the field with value 'X'.
SORT it_stpo BY idnrk.
SORT it_mbew_1 BY matnr.
LOOP AT it_mbew_1 INTO wa_mbew_1.
CLEAR WA_STPO.
READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr
flag = 'X'.
if sy-subrc eq 0.
move ' ' to wa_stpo-flag.
modify it_stpo from wa_stpo index sy-tabix.
wa_mbew_1-stlnr = wa_stpo-stlnr.
MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
endif.
ENDLOOP.Regards
Vinod
‎2010 Apr 26 12:32 PM
HI,
Just try this way.
SORT it_stpo BY idnrk.
SORT it_mbew_1 BY matnr.
LOOP AT it_mbew_1 INTO wa_mbew_1.
do.
if sy-index eq 1.
READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr BINARY SEARCH .
w_tabix = sy-tabix.
else.
READ TABLE it_stpo index w_tabix INTO wa_stpo comparing idrnk.
endif.
IF sy-subrc = 0.
wa_mbew_1-stlnr = wa_stpo-stlnr.
MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
else.
exit.
ENDIF.
endoo.
ENDLOOP.
‎2010 Apr 26 12:48 PM
The relationship between two itabs are not unique, there must be atleast a unique field to relate both.
How did you populate mbew ?
Edited by: Keshav.T on Apr 26, 2010 5:19 PM