Application Development 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: 

Calculate the Quntity by plant wise

Former Member
0 Kudos

Hi Friends,

This is Small and pecular but still iam not getting..

In mseg table Plant (werks) qunatity (menge) and movement type(bwart) and materail(matnr) and material document (MBlnr) is thesre..

I want calculete the qunatity of each plant by the movement type..

here is the problem is... I want calculte quntities by plant..

AT end of ,..

sum.

end at

and collect is its not working..

iwant calulcte the quantity and pass another internal table for for loop and display in differnt rows..

but the calculation is not comming proper..

if wewant all at atimens

we can calulate in loop.

but here plant wise calculation is giving me the problem..

please help me..

iam doing for 6 movemnt type and getting 6 quantity amonts for particaular pant..

please suggetst me..

reagrds,

sam

2 REPLIES 2

Former Member
0 Kudos

Hi Sampath,

Try this below given logic,.

Declare a temporary internal table. Move all data from you main itab to the temporary itab.

Now,

LOOP AT MAINITAB.

AT END OF plant.

LOOP AT TEMPITAB WHERE PLANT = plant.

AT END OF Mvmttype.

SUM up the quantity here.

ENDAT.

ENDLOOP.

ENDAT.

ENDLOOP.

<b>Reward points for informatory answers.</b>

Best Regards,

Ram.

varma_narayana
Active Contributor
0 Kudos

Hi..

You can to use this code:

DATA : BEGIN OF ITAB OCCURS 10,

WERKS TYPE MSEG-WERKS,

BWART TYPE MSEG-BWART,

MBLNR TYPE MSEG-MBLNR,

MENGE TYPE MSGE-MENGE,

END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 10,

WERKS TYPE MSEG-WERKS,

BWART TYPE MSEG-BWART,

MENGE TYPE MSGE-MENGE,

END OF ITAB1.

SELECT WERKS BWART MATNR MENGE

FROM MSEG INTO TABLE ITAB.

LOOP AT ITAB.

COLLECT ITAB INTO ITAB1.

ENDLOOP.

<b>Reward if Helpful</b>