SELECT pha.segment1 "PO_NO",
pha.creation_date "PO_DATE",
aps.vendor_name,
SUM(pla.quantity) "PO_QTY",
rsh.receipt_num,
rsl.quantity_received "RECEIPT_QTY",
(rsl.quantity_received * pla.unit_price) "RECEIPT_VALUE",
(rsl.quantity_received - rsl.quantity_shipped) "PENDING_QTY",
(pla.unit_price * pla.quantity) "PO_VALUE",
plla.promised_date "DELIVERY_SCHEDULE",
rt.transaction_date "RECEIPT_DATE",
apsa.amount_remaining "INVOICE_VALUE",
aia.invoice_num "INVOICE_NUMBER",
aia.invoice_date,
rt.attribute2 "LR_NO",
rt.attribute3 "LR_DATE"
FROM po_headers_all pha,
po_lines_all pla,
jai_po_taxes jpo,
po_line_locations_all plla,
po_distributions_all pda,
ap_suppliers aps,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
rcv_transactions rt,
ap_invoice_lines_all aila,
ap_invoices_all aia,
ap_payment_schedules_all apsa,
hr_organization_units hou,
mtl_system_items msi
WHERE pha.vendor_id= aps.vendor_id
AND pha.po_header_id=pla.po_header_id
AND jpo.po_line_id(+) = pla.po_line_id
AND pla.po_header_id = plla.po_header_id
AND pha.po_header_id = pda.po_header_id
AND pla.po_line_id = plla.po_line_id
AND plla.line_location_id = pda.line_location_id
AND rsh.shipment_header_id=rt.shipment_header_id
AND rt.shipment_line_id= rsl.shipment_line_id
AND pda.po_distribution_id=rt.po_distribution_id
AND pda.po_distribution_id = aila.po_distribution_id
AND aila.invoice_id = aia.invoice_id
AND apsa.invoice_id = aia.invoice_id
AND hou.organization_id = pha.org_id
AND pla.item_id = msi.inventory_item_id
AND plla.ship_to_organization_id = msi.organization_id
AND TRUNC (rsh.creation_date) BETWEEN NVL (:FROM_RECEIPT_DATE,TO_DATE
(rsh.creation_date,'DD-MON-RR')) AND NVL (:TO_RECEIPT_DATE,TO_DATE
(rsh.creation_date,'DD-MON-RR'))
AND pha.segment1=:PO_NUMBER
AND aps.vendor_name = NVL (:VENDOR_NAME, aps.vendor_name)
GROUP BY pha.segment1,
pha.creation_date,
aps.vendor_name,
pla.quantity,
rsh.receipt_num,
rsl.quantity_received,
rsl.quantity_received,
pla.unit_price,
rsl.quantity_received,
rsl.quantity_shipped,
plla.promised_date,
rt.transaction_date,
apsa.amount_remaining,
aia.invoice_num,
aia.invoice_date,
rt.attribute2,
rt.attribute3
pha.creation_date "PO_DATE",
aps.vendor_name,
SUM(pla.quantity) "PO_QTY",
rsh.receipt_num,
rsl.quantity_received "RECEIPT_QTY",
(rsl.quantity_received * pla.unit_price) "RECEIPT_VALUE",
(rsl.quantity_received - rsl.quantity_shipped) "PENDING_QTY",
(pla.unit_price * pla.quantity) "PO_VALUE",
plla.promised_date "DELIVERY_SCHEDULE",
rt.transaction_date "RECEIPT_DATE",
apsa.amount_remaining "INVOICE_VALUE",
aia.invoice_num "INVOICE_NUMBER",
aia.invoice_date,
rt.attribute2 "LR_NO",
rt.attribute3 "LR_DATE"
FROM po_headers_all pha,
po_lines_all pla,
jai_po_taxes jpo,
po_line_locations_all plla,
po_distributions_all pda,
ap_suppliers aps,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
rcv_transactions rt,
ap_invoice_lines_all aila,
ap_invoices_all aia,
ap_payment_schedules_all apsa,
hr_organization_units hou,
mtl_system_items msi
WHERE pha.vendor_id= aps.vendor_id
AND pha.po_header_id=pla.po_header_id
AND jpo.po_line_id(+) = pla.po_line_id
AND pla.po_header_id = plla.po_header_id
AND pha.po_header_id = pda.po_header_id
AND pla.po_line_id = plla.po_line_id
AND plla.line_location_id = pda.line_location_id
AND rsh.shipment_header_id=rt.shipment_header_id
AND rt.shipment_line_id= rsl.shipment_line_id
AND pda.po_distribution_id=rt.po_distribution_id
AND pda.po_distribution_id = aila.po_distribution_id
AND aila.invoice_id = aia.invoice_id
AND apsa.invoice_id = aia.invoice_id
AND hou.organization_id = pha.org_id
AND pla.item_id = msi.inventory_item_id
AND plla.ship_to_organization_id = msi.organization_id
AND TRUNC (rsh.creation_date) BETWEEN NVL (:FROM_RECEIPT_DATE,TO_DATE
(rsh.creation_date,'DD-MON-RR')) AND NVL (:TO_RECEIPT_DATE,TO_DATE
(rsh.creation_date,'DD-MON-RR'))
AND pha.segment1=:PO_NUMBER
AND aps.vendor_name = NVL (:VENDOR_NAME, aps.vendor_name)
GROUP BY pha.segment1,
pha.creation_date,
aps.vendor_name,
pla.quantity,
rsh.receipt_num,
rsl.quantity_received,
rsl.quantity_received,
pla.unit_price,
rsl.quantity_received,
rsl.quantity_shipped,
plla.promised_date,
rt.transaction_date,
apsa.amount_remaining,
aia.invoice_num,
aia.invoice_date,
rt.attribute2,
rt.attribute3
No comments:
Post a Comment