SELECT CITV.ITEM_NUMBER AS ITEM_NUMBER,
aila.INVENTORY_ITEM_ID ,
ROUND(CITV.ITEM_COST,5) AS INV_ITEM_UNIT_COST,
PHA.SEGMENT1 PO_NUMBER,
PLA.UNIT_PRICE AS PURCHASE_UNIT_PRICE,
AIA.INVOICE_DATE,
AIA.INVOICE_NUM,
AILA.QUANTITY_INVOICED AS AP_INVOICED_QUANTITY,
aida.unit_price ap_inv_unit_price,
aida.amount ipv_amount
FROM PO.PO_HEADERS_ALL PHA,
PO.PO_LINES_ALL PLA,
PO.PO_LINE_LOCATIONS_ALL PLLA,
PO.PO_DISTRIBUTIONS_ALL PDA,
AP.AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
ap_invoice_lines_all AILA,
AP.AP_INVOICES_ALL AIA,
CST_ITEM_COST_TYPE_V CITV
WHERE
PHA.PO_HEADER_ID
= PLA.PO_HEADER_ID
AND
PLA.PO_LINE_ID
=PLLA.PO_LINE_ID
AND
PLLA.LINE_LOCATION_ID
=PDA.LINE_LOCATION_ID
AND
PDA.PO_DISTRIBUTION_ID
=AIDA.PO_DISTRIBUTION_ID
AND
AILA.LINE_NUMBER
=AIDA.DISTRIBUTION_LINE_NUMBER
AND AIDA.INVOICE_ID
=AIA.INVOICE_ID
AND AIDA.inventory_transfer_status IS NOT NULL
AND
AILA.INVOICE_ID
= aida.INVOICE_ID
AND
CITV.INVENTORY_ITEM_ID
=PLA.ITEM_ID
AND
CITV.ORGANIZATION_ID
= PLLA.SHIP_TO_ORGANIZATION_ID
AND aida.LINE_TYPE_LOOKUP_CODE
= 'IPV'
-- and aida.INVOICE_DISTRIBUTION_ID=566513
ORDER BY CITV.ITEM_NUMBER,
AIA.INVOICE_DATE,
PHA.SEGMENT1,
PO_NUMBER,
PLA.LINE_NUM,
AILA.INVENTORY_ITEM_ID;
No comments:
Post a Comment