Summation of amount and quantity
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.
Tags:
sumi girijan replied
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