cancel
Showing results for 
Search instead for 
Did you mean: 

netting the open quantity

Former Member
0 Kudos

Hi Guys,

I have PO quantity(EKPO-MENGE) and goods receipt quantity(MSEG-ERFMG). Here i want to calculate the open PO quantity which is EKPO-MENGE - MSEG-ERFMG .But here if multiple material docements r getting created for the same for one PO and partial goods receipt quantity is done thru these multiple material documents. then how to net the open quantity.

For example :

PO no PO quantity material documents GR quantity

10 10 100 1

200 2

300 -2

400 3

Now i need the open quantity as 9

7

9

6.

Even i tried with At new Ebeln.but i am not getting it.

Can anybody help me in this.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

thanks a lot for ur help

Former Member
0 Kudos

Hi,

Open PO Line Item Qty = PO Line Item Qty - ( Sum(All GR Qty for PO Line Item ) -

Sum(All GR Return Qty for PO Line Item) ).

PO Line Item Qty = EKPO-MENGE.

GR QTY for PO Line Item = EKBE-MENGE with Movement Type = '101'.

GR Return QTY for PO Line Item = EKBE-MENGE with Movement Type = '102'.

SELECT EKPOMENGE EKPOMEINS

FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN

INNER JOIN EKET ON EKETEBELN = EKPOEBELN AND

EKETEBELP = EKPOEBELP

INNER JOIN LFA1 ON LFA1LIFNR = EKKOLIFNR

INTO CORRESPONDING FIELDS OF TABLE I_PO

WHERE EKKO~BUKRS = P_BUKRS AND

EKPO~WERKS = P_WERKS AND

EKKO~LIFNR IN S_LIFNR AND

EKPO~MEINS IN S_MEINS AND

EKET~EINDT IN S_EINDT AND

EKKO~BSTYP = 'F' AND "Select PO Only"

EKKO~LOEKZ = ' ' AND "PO should not be deleted"

EKPO~LOEKZ = ' ' . "Line Item Should not be DEL

Fetch the PO History Details for the Records of the Internal Table i_po.

LOOP AT I_PO.

SELECT EBELN EBELP BWART MENGE WRBTR

FROM EKBE

APPENDING CORRESPONDING FIELDS OF TABLE I_EKBE

WHERE EBELN = I_PO-EBELN AND

EBELP = I_PO-EBELP AND

BEWTP IN ('E','F').

ENDLOOP.

Edited by: AJAY TIWARI on Oct 19, 2008 5:00 PM

Former Member
0 Kudos

use EKBE instead of MSEG for PO history, GR is event type '1', and you can total up all the lines in EKBE for that PO Line item and then get the open quantity by using EKPO-MENGE - total of EKBE-MENGE