05-28-2010 4:37 AM
Hi experts,
I use the following code to get the remaining qty in PO:
SELECT ERFMG from MSEG into wa_qty where EBELN = PO_NUMBER AND EBELP = PO_ITEM AND MATNR = ARTICLENO .
QUANTITY = QUANTITY - wa_qty.
ENDSELECT.
But it's very slow.How to optimize it?
thanks.
05-28-2010 9:07 PM
i think table MDUB will help you , it holds the cumulated values for each PO line item.
There will be two quantity fields ( just subtract it )
If you are using mseg or ekbe use movement types for quantity calculation , some entries might be reversed after posting.
05-28-2010 5:42 AM
Hi,
Instead of using SELECT ENDSELECT use SELECT INTO TABLE.
TYPES: BEGIN OF TY_QTY,
ERFMG TYPE ERFMG,
END OF TY_QTY.
DATA : IT_QTY TYPE TABLE OF TY_QTY,
WA_QTY TYPE TY_QTY,
QUANTITY TYPE ERFMG.
SELECT ERFMG from MSEG into table it_qty where EBELN = PO_NUMBER AND EBELP = PO_ITEM AND MATNR = ARTICLENO .
LOOP AT IT_QTY INTO WA_QTY.
QUANTITY = QUANTITY - wa_qty-erfmg.
ENDLOOP.
05-28-2010 5:44 AM
05-28-2010 5:46 AM
Hi,
Use table EKBE instead of MSEG.
Select ebeln ebelp belnr buzei menge
from ekbe
where ebeln = <po_number>
and ebelp = <po_lineitem>
and vgabe = '1'.
Deduct the Quantity(MENGE) of previous query from Purchase order line item quantity to get balance quantity.
Regards
Vinod
05-28-2010 9:07 PM
i think table MDUB will help you , it holds the cumulated values for each PO line item.
There will be two quantity fields ( just subtract it )
If you are using mseg or ekbe use movement types for quantity calculation , some entries might be reversed after posting.