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

Query

Former Member
0 Likes
347

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

2 REPLIES 2
Read only

Former Member
0 Likes
303

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

Read only

Former Member
0 Likes
303

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