04-01-2013 6:52 PM
Hi All,
Please help me on this:
I'm retrieving the delivered items from EKBE table based on movement type 101/102/103/104.
so my internal table has so many multiple record for one item based on the movement type. My requirement is calculating the total quantity for each item considering the movement type, then I should have only one record includes po#,item#, and total received qty.
for example :
itab :
ebeln ebelp bwart menge wesas
4500000555 10 101 500 0
4500000555 10 102 200 0
4500000555 10 101 100 0
4500000555 20 103 0 70
4500000555 20 104 0 40
4500000666 10 101 800 0
the resulte shold be (on new table) :
ebeln ebelp bamng
4500000555 10 600
4500000555 20 70
4500000666 10 800
whiting your ideas ...
Thanks
huss
04-02-2013 2:41 PM
Dear Developer ,
For this type calculation I feel COLLECT statement is the better one and you can using COLLECT statement as shown below ,
clear itab .
loop at itab .
clear : itab-ebelp , itab-bwart.
collect itab into itab1[] .
endloop .
Thanks
Mallikarjun
04-02-2013 2:41 PM
Dear Developer ,
For this type calculation I feel COLLECT statement is the better one and you can using COLLECT statement as shown below ,
clear itab .
loop at itab .
clear : itab-ebelp , itab-bwart.
collect itab into itab1[] .
endloop .
Thanks
Mallikarjun
04-03-2013 8:43 AM
Thank you Mallikarjun,
I was trying to use COLLECT but my problem was on bwart value as the 102 & 104 should be subtracted from the total, and because of change of movement type, the result of COLLECT statement was not correct.
Your idea to clear BWART guided me to resolve this issue, as I assigned -ve sign to all 102/104 quantities then clear BWART.
my code became like this :
LOOP AT ITAB.
IF T_DEL-BWART EQ '102'.
ITAB-MENGE = ITAB-MENGE * -1.
MODIFY ITAB.
ELSEIF ITAB-BWART EQ '104'.
ITAB-WESBS = ITAB-WESBS * -1.
MODIFY ITAB.
ENDIF.
CLEAR ITAB-BWART.
COLLECT ITAB INTO ITAB2.
ENDLOOP.
Thanks,
Huss