09-16-2008 4:45 PM
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.
09-16-2008 6:03 PM
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
09-16-2008 4:47 PM
09-16-2008 6:11 PM
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.
09-16-2008 6:20 PM
Hi,
Please see the solution I have provided. I haven't included the field MBLNR to my new internal table.
Try this.
Thanks
Sumi
09-16-2008 6:39 PM
09-16-2008 4:52 PM
Dear krupali,
For your requirement use collect statement.Here to use collect statement remove ebelp field.
warm regards,
surendar reddy.
09-16-2008 4:52 PM
Dear krupalli,
For your requirement use collect statement.Here to use collect statement remove ebelp field.
warm regards,
surendar reddy.
09-16-2008 6:03 PM
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
09-17-2008 7:23 AM
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.
09-17-2008 9:38 AM