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

ABAP Report Problem

Former Member
0 Likes
417

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...

2 REPLIES 2
Read only

_IvanFemia_
Active Contributor
0 Likes
391

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
391

Classic or ALV report ??