‎2006 Aug 24 12:37 PM
hi friends,
Could u help me how to write this code
Sum up all the Quantities (MSEG-MENGE) for the batch entered on the selection screen where the movement type (MSEG-BWART) equals 101, 561, 563 and 565 and subtract the summed quantities (MSEG-MENGE) where the movement type (MSEG-BWART) equals 102, 562, 564 and 566. The quantities can be summed by selecting the quantity (MSEG-MENGE) from the table MSEG where the batch number (MSEG-CHARG) equals the batch number entered on the selection screen. Quantity will be displayed with 2 decimal places.
Regards
srinu
‎2006 Aug 24 12:43 PM
select charg bwart menge
into itab
from mseg
where charg = pcharg
and bwart in ('101','561'....) "your complete list.
sort itab.
loop at itab
at new charg.
ltot = 0.
endat.
if bwart in ('101','561'...) "all positive ones
ltot = ltot + itab-menge.
else.
ltot = ltot - itab-menge.
endif.
at end of charg.
write : / charg, ltot.
endat.
endloop.
--please note to define ltot with 2 decimals as it is your requirement
--Note that you can even use the Debit/Credit indicator to do the needful for add or subtract
Message was edited by: Anurag Bankley
‎2006 Aug 24 1:00 PM
HI Srinu
Apart from the logic provided by Anurag, you can also
extract SHKZG(Debit/Credit) Indicator from MSEG for
summing and subtracting the quantities.
Kind Regards
Eswar