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: 

Summation of amount and quantity

Former Member
0 Kudos

Hi all,

I have the ITAB_MSEG as follows.

wa_mseg-mblnr = '5000000130'. "Number of Article Document

wa_mseg-mjahr = '2008'. "Article Document Year

wa_mseg-bwart = '901'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000005000'. "Amount in Local Currency

wa_mseg-bpmng = '00000000100'. "Quantity in Purchase Order Price Unit

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

APPEND wa_mseg to itab_mseg.

wa_mseg-mblnr = '5000000131'. "Number of Article Document

wa_mseg-mjahr = '2008'. "Article Document Year

wa_mseg-bwart = '902'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000002500'. "Amount in Local Currency

wa_mseg-bpmng = '00000000050'. "Quantity in Purchase Order Price Unit

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

APPEND wa_mseg to itab_mseg.

wa_mseg-mblnr = '5000000132'.

wa_mseg-mjahr = '2008'.

wa_mseg-bwart = '901'.

wa_mseg-dmbtr = '00000002500'.

wa_mseg-bpmng = '00000000050'.

wa_mseg-ebeln = '1059200855'.

wa_mseg-ebelp = '00010'.

APPEND wa_mseg to itab_mseg.

-


wa_mseg-mblnr = '5000000133'. "Number of Article Document

wa_mseg-mjahr = '2008'. "Article Document Year

wa_mseg-bwart = '901'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000005000'. "Amount in Local Currency

wa_mseg-bpmng = '00000000100'. "Quantity in Purchase Order Price Unit

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00011'. "Item Number of Purchasing Document

APPEND wa_mseg to itab_mseg.

wa_mseg-mblnr = '5000000134'. "Number of Article Document

wa_mseg-mjahr = '2008'. "Article Document Year

wa_mseg-bwart = '902'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000002500'. "Amount in Local Currency

wa_mseg-bpmng = '00000000050'. "Quantity in Purchase Order Price Unit

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00011'. "Item Number of Purchasing Document

APPEND wa_mseg to itab_mseg.

wa_mseg-mblnr = '5000000135'.

wa_mseg-mjahr = '2008'.

wa_mseg-bwart = '901'.

wa_mseg-dmbtr = '00000002500'.

wa_mseg-bpmng = '00000000050'.

wa_mseg-ebeln = '1059200855'.

wa_mseg-ebelp = '00011'.

APPEND wa_mseg to itab_mseg.

-


My requirement is to calculate the SUmof DMBTR (Amount) & BPMNG (Quantity) for the PO with same Moment type.901 & with Item No 10

i mean for the PO 1059200855 & Item no 10 & moment type 901

i want to add the all AMounts and Quantity fields.

and for the PO 1059200855 & Item no 10 & moment type 902

i want to add the all AMounts and Quantity fields.

&

and for the PO 1059200855 & Item no 11 & moment type 901

i want to add the all AMounts and Quantity fields.

and for the PO 1059200855 & Item no 11 & moment type 902

i want to add the all AMounts and Quantity fields.

if any one has came across such requirent, pls give any idea or sample code.

Thanks

Krupali.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Group your key fields( here PO,itemno,movement type) along with the quantity and amount fields to an internal table say itab_mseg1. then try "Collect" statement as follows:

data : itab_mseg type table of mseg,

itab_mseg1 type table of mseg,

wa_mseg like line of itab_mseg.

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

wa_mseg-bwart = '902'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000002500'. "Amount in Local Currency

wa_mseg-bpmng = '00000000050'. "Quantity in Purchase Order Price Unit

APPEND wa_mseg to itab_mseg1.

wa_mseg-ebeln = '1059200855'.

wa_mseg-ebelp = '00010'.

wa_mseg-bwart = '901'.

wa_mseg-dmbtr = '00000002500'.

wa_mseg-bpmng = '00000000050'.

APPEND wa_mseg to itab_mseg1.

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

wa_mseg-bwart = '901'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000005000'. "Amount in Local Currency

wa_mseg-bpmng = '00000000100'. "Quantity in Purchase Order Price Unit

APPEND wa_mseg to itab_mseg1.

loop at itab_mseg1 into wa_mseg.

collect wa_mseg into itab_mseg.

endloop.

Thanks

Sumi

9 REPLIES 9

Former Member
0 Kudos

Try using statement COLLECT .

A

0 Kudos

Hi ,

I cannot use the COLLECT Statement, because of the field mblnr. What ever may be the value of mblnr, for same moment type and same PO and same Item no i want to add the Amount and Quantity fields.

Any other ideas pls...

Thanks

Krupali.

0 Kudos

Hi,

Please see the solution I have provided. I haven't included the field MBLNR to my new internal table.

Try this.

Thanks

Sumi

0 Kudos

Hi Sumi,

Thanks !!

i want the solution with field MBLNR

0 Kudos

Dear krupali,

For your requirement use collect statement.Here to use collect statement remove ebelp field.

warm regards,

surendar reddy.

0 Kudos

Dear krupalli,

For your requirement use collect statement.Here to use collect statement remove ebelp field.

warm regards,

surendar reddy.

Former Member
0 Kudos

Hi,

Group your key fields( here PO,itemno,movement type) along with the quantity and amount fields to an internal table say itab_mseg1. then try "Collect" statement as follows:

data : itab_mseg type table of mseg,

itab_mseg1 type table of mseg,

wa_mseg like line of itab_mseg.

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

wa_mseg-bwart = '902'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000002500'. "Amount in Local Currency

wa_mseg-bpmng = '00000000050'. "Quantity in Purchase Order Price Unit

APPEND wa_mseg to itab_mseg1.

wa_mseg-ebeln = '1059200855'.

wa_mseg-ebelp = '00010'.

wa_mseg-bwart = '901'.

wa_mseg-dmbtr = '00000002500'.

wa_mseg-bpmng = '00000000050'.

APPEND wa_mseg to itab_mseg1.

wa_mseg-ebeln = '1059200855'. "Purchasing Document Number

wa_mseg-ebelp = '00010'. "Item Number of Purchasing Document

wa_mseg-bwart = '901'. "Movement Type (Inventory Management)

wa_mseg-dmbtr = '00000005000'. "Amount in Local Currency

wa_mseg-bpmng = '00000000100'. "Quantity in Purchase Order Price Unit

APPEND wa_mseg to itab_mseg1.

loop at itab_mseg1 into wa_mseg.

collect wa_mseg into itab_mseg.

endloop.

Thanks

Sumi

0 Kudos

hi,

If you want totals based on the mblnr then use control break statements.Use ALV report you can easily do totals.

Best Regards,

surendar reddy.

0 Kudos

resolved

Thanks for all inputs