Introduction
P2P
Procure-to-Pay in Oracle E-Business Suite (EBS) is a fully integrated business
process followed by any organization that handles from requesting
goods or services to paying the supplier and accounting for the transaction.
In this
article i discuss commonly used P2P queries for reporting and analysis.
1. Purchase
Order Details
Purpose: Fetch PO header and line details along with the linked supplier
pha.segment1 AS po_number,
pha.type_lookup_code AS po_type,
pha.authorization_status,
pha.creation_date,
aps.vendor_name,
aps.segment1 AS supplier_number,
pla.line_num,
pla.item_description,
pla.quantity,
pla.unit_price,
(pla.quantity * pla.unit_price) AS
line_amount
FROM
po_headers_all pha
JOIN
po_lines_all pla
ON pha.po_header_id = pla.po_header_id
JOIN
ap_suppliers aps
ON pha.vendor_id = aps.vendor_id
pha.segment1, pla.line_num;
2. PO with Receipt Details
Purpose: Fetches
the quantity received and accepted against each PO line.
SELECT
pha.segment1 AS po_number,
pla.line_num,
rsh.receipt_num,
rsh.creation_date AS receipt_date,
CASE
WHEN rt.transaction_type =
'RECEIVE' THEN rt.quantity
WHEN rt.transaction_type = 'RETURN
TO VENDOR' THEN -rt.quantity
ELSE 0
END
) AS quantity_received,
CASE
WHEN rt.transaction_type = 'ACCEPT'
THEN rt.quantity
ELSE 0
END
) AS quantity_accepted
po_headers_all pha
po_lines_all pla
ON pha.po_header_id = pla.po_header_id
po_line_locations_all pll
ON pla.po_line_id = pll.po_line_id
rcv_transactions rt
ON pll.line_location_id =
rt.po_line_location_id
rcv_shipment_headers rsh
ON rt.shipment_header_id = rsh.shipment_header_id
rt.source_document_code = 'PO'
AND pha.authorization_status = 'APPROVED'
AND NVL(pha.cancel_flag, 'N') = 'N'
AND NVL(pla.cancel_flag, 'N') = 'N'
AND NVL(pll.cancel_flag, 'N') = 'N'
pha.segment1,
pla.line_num,
rsh.receipt_num,
rsh.creation_date
pha.segment1,
pla.line_num,
rsh.creation_date;
3. Open Purchase Orders (Not Fully Received)
Purpose: Identifies PO lines where the full
ordered quantity has not yet been received.
SELECT
pha.segment1 AS po_number,
pha.creation_date,
pha.authorization_status,
pla.item_description,
pla.quantity AS ordered_qty,
po_headers_all pha
po_lines_all pla
ON pha.po_header_id = pla.po_header_id
po_line_locations_all pll
ON pla.po_line_id = pll.po_line_id
LEFT JOIN
(
SELECT
rt.po_line_location_id,
SUM(
CASE
WHEN rt.transaction_type = 'RECEIVE'
THEN rt.quantity
WHEN rt.transaction_type = 'RETURN
TO VENDOR' THEN -rt.quantity
ELSE 0
END
) AS received_qty
FROM
rcv_transactions rt
WHERE
rt.source_document_code = 'PO'
GROUP BY
rt.po_line_location_id
) r
ON pll.line_location_id =
r.po_line_location_id
(pll.quantity - NVL(r.received_qty, 0))
> 0
AND NVL(pha.cancel_flag, 'N') = 'N'
AND NVL(pla.cancel_flag, 'N') = 'N'
AND NVL(pll.cancel_flag, 'N') = 'N'
ORDER BY
pha.creation_date DESC,
pha.segment1,
pla.line_num;
Purpose: Lists invoices with supplier names, amounts,
and payment status.
SELECT
aia.invoice_id,
aia.invoice_num,
aia.invoice_date,
aia.invoice_amount,
aps.vendor_name,
CASE
WHEN NVL(aia.amount_paid, 0) =
aia.invoice_amount THEN 'Paid'
WHEN NVL(aia.amount_paid, 0) = 0 THEN 'Unpaid'
WHEN NVL(aia.amount_paid, 0) > 0
AND NVL(aia.amount_paid, 0) <
aia.invoice_amount THEN 'Partially Paid'
ELSE 'Unknown'
END AS payment_status,
ap_invoices_all aia
ap_suppliers aps
ON aia.vendor_id = aps.vendor_id
aia.cancelled_date IS NULL
AND aia.invoice_type_lookup_code = 'STANDARD'
ORDER BY
aia.invoice_date DESC;
5. Outstanding
Invoices
Purpose: Returns invoices
with an outstanding balance.
aia.invoice_id,
aia.invoice_num,
aia.invoice_amount,
apsup.vendor_name,
MIN(aps.due_date) AS next_due_date
ap_invoices_all aia
ap_payment_schedules_all aps
ON aia.invoice_id = aps.invoice_id
ap_suppliers apsup
ON aia.vendor_id = apsup.vendor_id
aps.amount_remaining > 0
AND aia.cancelled_date IS NULL
aia.invoice_id,
aia.invoice_num,
aia.invoice_amount,
apsup.vendor_name
next_due_date;
6. Supplier
Wise Spend Analysis
Purpose: Analyzes total invoice spend, number of invoices, and payments made for each supplier.
SELECT
aps.vendor_id,
aps.vendor_name,
ap_invoices_all aia
ap_suppliers aps
ON aia.vendor_id = aps.vendor_id
aia.cancelled_date IS NULL
AND aia.invoice_type_lookup_code =
'STANDARD'
AND aia.payment_status_flag = 'Y'
aps.vendor_id,
aps.vendor_name
total_spend DESC;
7. Cancelled
Purchase Orders
Purpose: Retrieves all POs that have been
cancelled.
SELECT
segment1
AS po_number,
authorization_status,
cancel_flag
FROM po_headers_all
WHERE
(
NVL(cancel_flag, 'N') = 'Y'
OR authorization_status = 'CANCELLED'
);
8. PO Receiving
Transactions (Receipt & Shipment
Level)
Purpose: This query
retrieves all
receiving transactions recorded against a Purchase Order at the
shipment
level
SELECT
pha.segment1 AS po_number,
pla.line_num AS po_line_number,
pla.item_description AS item_description,
pll.shipment_num AS shipment_number,
rsh.receipt_num AS receipt_number,
rt.transaction_type AS transaction_type,
rt.quantity AS transaction_quantity,
rt.unit_of_measure AS uom,
rt.transaction_date AS transaction_date
FROM
po_headers_all pha
JOIN
po_lines_all pla
ON pha.po_header_id = pla.po_header_id
JOIN po_line_locations_all pll
ON pla.po_line_id = pll.po_line_id
JOIN
rcv_transactions rt
ON pll.line_location_id =
rt.po_line_location_id
JOIN
rcv_shipment_headers rsh
ON rt.shipment_header_id =
rsh.shipment_header_id
rt.transaction_date
>= :p_from_date ------ e.g rt.transaction_date >= '01-Jan-2026'
AND
rt.transaction_date < :p_to_date ------- e.g rt.transaction_date <
'15-Apr-2026'
AND pha.authorization_status = 'APPROVED'
AND NVL(pha.cancel_flag,'N') = 'N'
AND NVL(pla.cancel_flag,'N') = 'N'
AND NVL(pll.cancel_flag,'N') = 'N'
AND rt.source_document_code = 'PO'
AND rt.transaction_type IN
('RECEIVE','RETURN TO VENDOR')
ORDER BY
pha.segment1,
pla.line_num,
pll.shipment_num,
rt.transaction_date;
9. PO Approval Status Report
Purpose: Reports PO
approval status with creation and approval dates
SELECT
pha.segment1 AS po_number,
pha.authorization_status,
pha.creation_date,
MAX(pah.action_date) AS approved_date
FROM po_headers_all
pha
LEFT JOIN
po_action_history pah
ON pha.po_header_id = pah.object_id
AND pah.object_type_code = 'PO'
AND pah.action_code = 'APPROVE'
WHERE
pha.creation_date >= :P_FROM_DATE ----pha.creation_date >= '01-Apr-2026'
AND
pha.creation_date < :P_TO_DATE---- pha.creation_date < '14-Apr-2026'
AND pha.authorization_status = 'APPROVED'
GROUP BY
pha.segment1,
pha.authorization_status,
pha.creation_date
ORDER BY
pha.creation_date DESC;
These
queries cover the most commonly needed P2P scenarios in Oracle EBS
R12,
Including Purchase Orders, Receiving,
Invoicing, Payments, and Supplier Analysis









Comments
Post a Comment