03-24-2015 2:28 PM
I have a requirement to retrieve an actual price based on an intercompany transport order line item based on the below scenarios:
I thought I could just grab the fields EKPO-ELIKZ (Delivery Indicator, ‘X’) and EKPO-EREKZ (Final invoice indicator, ‘X’) to by the purchase order number and line item and get the desired results. After debugging, I’m not sure this is completely accurate and was wondering if there were additional steps I need to consider? Any help would be appreciated!
Here is my current code section I applied this to:
[code]
SELECT SINGLE elikz erekz FROM ekpo
INTO (gr_indicator, invoice_indicator)
WHERE ebeln EQ materials-ebeln
AND ebelp EQ materials-ebelp.
IF gr_indicator = 'X' AND invoice_indicator IS INITIAL.
IF post_per NE materials-wadat+4(2). "If posting period does not equal the goods issue date, use goods issue date
poper = materials-wadat+4(2).
bdatj = materials-wadat(4).
ELSE. "Get previous month of goods issue date
IF materials-wadat+4(2) EQ '01'.
poper = 12.
bdatj = materials-wadat(4) - 1.
ELSE.
poper = materials-wadat+4(2) - 1.
bdatj = materials-wadat(4).
ENDIF.
ENDIF.
ELSEIF invoice_indicator = 'X' AND gr_indicator IS INITIAL. "Use current month of goods issue date
"Use current rate
poper = materials-wadat+4(2).
bdatj = materials-wadat(4).
ELSE. "No GR or IR "Catch all, use current month of goods issue date
poper = materials-wadat+4(2).
bdatj = materials-wadat(4).
ENDIF.
[/code]
03-24-2015 2:33 PM
I would use the PO history table (EKBE) instead. There may be partial deliveries that you have to decide how to handle and I don't think you can count on users to set the 'Final' indicators.
Rob