2010 Oct 02 4:24 PM
Hi,
My report output is like this..
Material Number......................Stock
AAAA.....................................00.00
BBBB.....................................100.00
CCCC.......................................50.00
DDDD.....................................200.00
..........................SUM.............350.00
Please have a look that SUM is 350.00 for 4 Material's Stock.
Now i want the output like this..
Material Number......................Stock
AAAA....................................350.00
BBBB..................................... 350.00
CCCC......................................350.00
DDDD..................................... 350.00
Sum should be shown in all 4 material.
My code for above example is...
**********************************************************************
LOOP AT itab.
AT NEW matnr.
stock = 0.
SELECT SINGLE labst INTO stock FROM mard WHERE matnr = itab-matnr AND werks = itab-werks AND lgort IN ('FNGS','DLF1').
ENDAT.
IF stock GE itab-omeng.
itab-labst = itab-omeng.
stock = stock - itab-omeng.
ELSE.
itab-labst = stock.
stock = 0.
ENDIF.
MODIFY itab TRANSPORTING labst.
ENDLOOP.
**********************************************************************
In addition, what should be do for 350.00 in all materials.
Plz guide...
2010 Oct 02 7:56 PM
Hi,
first of all avoid select into a loop
SELECT SUM(labst) as stock
FOR ALL ENTRIES IN itab
FROM mard WHERE matnr = mard-matnr AND werks = mard-werks AND mard-lgort IN ('FNGS','DLF1').
LOOP AT itab.
*** Write Output
ENDLOOP.
I have not tested the code but it is an idea.
Ivan
2010 Oct 03 6:41 PM