Oracle EBS Order-to-Cash SQL Generator: Sales Order to Delivery, Invoice and Receipt
This generator writes a single SQL statement that follows each Oracle EBS R12 sales order line from Order Management through Shipping Execution, Receivables invoicing and cash application. A second query shows lines that are sitting in the AutoInvoice interface instead of on an invoice.
Fill in
OE_ORDER_HEADERS_ALL.ORG_ID of the operating unit.
Leave blank to return all orders in the date range.
Matched case-insensitively against HZ_PARTIES.PARTY_NAME, use % as wildcard.
The value OM writes to INTERFACE_LINE_CONTEXT, controlled by the profile OM: Source Code. ORDER ENTRY is the seeded value.
1. Order line to delivery, invoice and receipt
-- Oracle EBS R12: Order-to-Cash trace for operating unit 204
-- One row per order line x delivery detail x invoice line x payment schedule x receipt application
SELECT h.order_number,
l.line_number || '.' || l.shipment_number AS line_no,
l.ordered_item,
l.ordered_quantity,
l.flow_status_code AS line_status,
l.invoice_interface_status_code,
p.party_name AS customer,
ca.account_number,
wdd.delivery_detail_id,
wdd.released_status,
wnd.name AS delivery_name,
rct.trx_number,
rct.trx_date,
ps.amount_due_original,
ps.amount_due_remaining,
cr.receipt_number,
ra.amount_applied
FROM oe_order_headers_all h
JOIN oe_order_lines_all l
ON l.header_id = h.header_id
JOIN hz_cust_accounts ca
ON ca.cust_account_id = h.sold_to_org_id
JOIN hz_parties p
ON p.party_id = ca.party_id
LEFT JOIN wsh_delivery_details wdd
ON wdd.source_line_id = l.line_id
AND wdd.source_code = 'OE'
LEFT JOIN wsh_delivery_assignments wda
ON wda.delivery_detail_id = wdd.delivery_detail_id
LEFT JOIN wsh_new_deliveries wnd
ON wnd.delivery_id = wda.delivery_id
LEFT JOIN ra_customer_trx_lines_all rctl
ON rctl.interface_line_context = 'ORDER ENTRY'
AND rctl.interface_line_attribute6 = TO_CHAR(l.line_id)
AND rctl.line_type = 'LINE'
LEFT JOIN ra_customer_trx_all rct
ON rct.customer_trx_id = rctl.customer_trx_id
LEFT JOIN ar_payment_schedules_all ps
ON ps.customer_trx_id = rct.customer_trx_id
LEFT JOIN ar_receivable_applications_all ra
ON ra.applied_customer_trx_id = rct.customer_trx_id
AND ra.status = 'APP'
AND ra.display = 'Y'
LEFT JOIN ar_cash_receipts_all cr
ON cr.cash_receipt_id = ra.cash_receipt_id
WHERE h.org_id = 204
AND h.order_number = NVL(TO_NUMBER('[Order number (optional)]'), h.order_number)
AND UPPER(p.party_name) LIKE UPPER('%')
AND h.ordered_date >= TO_DATE('2026-09-01', 'YYYY-MM-DD')
AND h.ordered_date < TO_DATE('2026-09-30', 'YYYY-MM-DD') + 1
ORDER BY h.order_number, l.line_number, l.shipment_number, rct.trx_number;2. Lines shipped but not invoiced: check the AutoInvoice interface
-- Rows still in RA_INTERFACE_LINES_ALL were interfaced by OM but not yet imported by AutoInvoice
SELECT ril.interface_line_id,
ril.interface_line_attribute1 AS order_number,
ril.interface_line_attribute6 AS oe_line_id,
ril.batch_source_name,
ril.request_id,
ril.interface_status,
rie.message_text,
rie.invalid_value
FROM ra_interface_lines_all ril
LEFT JOIN ra_interface_errors_all rie
ON rie.interface_line_id = ril.interface_line_id
WHERE ril.interface_line_context = 'ORDER ENTRY'
AND ril.org_id = 204
AND ril.interface_line_attribute1 = NVL('[Order number (optional)]', ril.interface_line_attribute1)
ORDER BY ril.interface_line_attribute1, ril.interface_line_id;Built from the standard R12 table relationships. Verify on your instance: the INTERFACE_LINE_CONTEXT value (profile OM: Source Code), that ATTRIBUTE1 holds the order number and ATTRIBUTE6 the OE line_id for that context, and the columns in your release. Rows multiply when a line has several deliveries, installments or receipt applications; aggregate before summing amounts. Run in a reporting or cloned instance for large date ranges.
Get this trace checked against your OM setup
Send us your transaction source and order types and we will confirm the joins and context values for your instance.
Optional. The tool and every export work without this. No spam.
How to use it
Enter the operating unit ORG_ID, an optional order number, a customer name pattern and the ordered date range, then copy the SQL into SQL Developer or TOAD connected as APPS (or a read-only reporting schema with grants and synonyms). Because the joins to shipping, invoicing and receipts are LEFT JOINs, every order line is returned even when it has not shipped or invoiced yet, so the null columns tell you where the line stopped. Read a row left to right: FLOW_STATUS_CODE and RELEASED_STATUS show the order and shipping stage, TRX_NUMBER appears once AutoInvoice has created the invoice, AMOUNT_DUE_REMAINING drops as cash is applied, and RECEIPT_NUMBER identifies the receipt.
- RELEASED_STATUS: R ready to release, S released to warehouse, Y staged, C shipped, B backordered, D cancelled.
- INVOICE_INTERFACE_STATUS_CODE YES means OM has passed the line to Receivables.
- Blank TRX_NUMBER with a shipped line: run query 2.
Where the links live in Oracle EBS
OE_ORDER_HEADERS_ALL.SOLD_TO_ORG_ID points to HZ_CUST_ACCOUNTS.CUST_ACCOUNT_ID, and the account points to HZ_PARTIES for the customer name. Shipping creates WSH_DELIVERY_DETAILS rows with SOURCE_CODE 'OE' and SOURCE_LINE_ID equal to the order line_id; WSH_DELIVERY_ASSIGNMENTS ties each detail to a WSH_NEW_DELIVERIES delivery. When the line workflow reaches the Invoice Interface activity, OM inserts into RA_INTERFACE_LINES_ALL using the line transaction flexfield: context ORDER ENTRY by default, ATTRIBUTE1 the order number, ATTRIBUTE6 the line_id. AutoInvoice copies those attributes onto RA_CUSTOMER_TRX_LINES_ALL, which is why the invoice join uses INTERFACE_LINE_ATTRIBUTE6 = TO_CHAR(line_id). AR_PAYMENT_SCHEDULES_ALL holds the open balance and AR_RECEIVABLE_APPLICATIONS_ALL (STATUS 'APP') links the invoice to AR_CASH_RECEIPTS_ALL.
Why a shipped line has no invoice
After ship confirm and Interface Trip Stop, the OEOL line workflow usually defers the invoice interface step, so nothing reaches Receivables until the Workflow Background Process runs for item type OEOL with deferred activities. Then AutoInvoice Master Program must run for the OM transaction source to turn the interface rows into invoices. If query 2 returns rows with messages in RA_INTERFACE_ERRORS_ALL, AutoInvoice rejected them: common causes are a closed GL period, a missing revenue or receivable account from AutoAccounting, an invalid or inactive bill-to site, or a missing transaction type on the order type. Fix the cause and rerun AutoInvoice. If there are no interface rows and the line status is still SHIPPED or AWAITING_FULFILLMENT, look at the line workflow in Workflow Status Monitor instead.
Gotchas and version notes
Each join can multiply rows: split shipments, partial backorders, invoices with several installments and receipts applied in pieces all add rows, so aggregate amounts at the right grain before summing. The DISPLAY = 'Y' filter keeps only the current application row and hides reversed pairs. Credit memos created from RMAs also come through the same context with the RMA line_id, and freight lines carry LINE_TYPE 'FREIGHT', which the filter excludes. Some sites change OM: Source Code or use a custom transaction source, so confirm the context name in the Line Transaction Flexfield before trusting empty invoice columns. The query is the same for 12.1 and 12.2.
Frequently Asked Questions
What is the order to cash process flow in Oracle EBS?
Enter and book the sales order in Order Management, pick release and ship confirm in Shipping Execution, run Interface Trip Stop, let the line workflow and Workflow Background Process interface the line to Receivables, run AutoInvoice to create the invoice, then enter or import a receipt and apply it. The tables follow the same path: OE, WSH, RA, AR_PAYMENT_SCHEDULES, AR_RECEIVABLE_APPLICATIONS and AR_CASH_RECEIPTS.
How do I join a sales order line to its AR invoice line?
Join RA_CUSTOMER_TRX_LINES_ALL on INTERFACE_LINE_CONTEXT = 'ORDER ENTRY' (or your OM: Source Code value) and INTERFACE_LINE_ATTRIBUTE6 = TO_CHAR(OE_ORDER_LINES_ALL.LINE_ID). INTERFACE_LINE_ATTRIBUTE1 holds the order number if you only need the header. Keep the context filter or you can match lines from other sources that use attribute6 differently.
Which table stores sales orders in Oracle EBS?
Headers are in OE_ORDER_HEADERS_ALL and lines in OE_ORDER_LINES_ALL, both striped by ORG_ID. Price adjustments are in OE_PRICE_ADJUSTMENTS and holds in OE_ORDER_HOLDS_ALL. The order number is ORDER_NUMBER on the header, and the user-visible line number is LINE_NUMBER plus SHIPMENT_NUMBER, shown as 1.1, 1.2 and so on.
Why does my O2C query return duplicate rows?
Each one-to-many step multiplies rows: one order line can have several delivery details after a split or backorder, one invoice can have several payment schedules, and one invoice can be paid by several receipts. Either report at that grain, or aggregate in an inline view (for example SUM(amount_applied) per customer_trx_id) before joining back to the order line.
If your order desk wants to ask where an order is in plain English and get this trace back from EBS on your own servers, we can set that up.
Related Tools
Oracle EBS TCA Customer Creation API Script Generator (HZ V2 APIs)
Generate one PL/SQL block that creates an organization customer with account, address and bill-to and ship-to site uses through the public TCA V2 APIs.
Developer ToolsOracle EBS Workflow Error and Notification SQL Generator
Generate the five queries and the PL/SQL retry block a workflow administrator needs: errored activities, open notifications, mailer backlog, deferred queue and retry.
OracleOracle EBS Customer and Supplier Tables Reference
Searchable list of the Trading Community Architecture customer tables and the supplier tables in Oracle EBS, with keys, join columns and where to confirm in the eTRM.
Developer ToolsOracle EBS Value Set, Lookup and DFF SQL Generator
Generate the queries that read value set definitions and values, rebuild a table-validated LOV, list FND lookup codes and map DFF segments to ATTRIBUTE columns.
More Oracle tools
See all- Oracle EBS Inventory Tables Reference
- Oracle EBS WIP Tables Reference
- Oracle EBS Cycle Count Workload Calculator
- Oracle EBS Discrete Manufacturing Go-Live Checklist
- Oracle EBS Inventory Accuracy Readiness Assessment
- Oracle EBS Concurrent Request Phase and Status Reference
- Oracle EBS Responsibility Design Worksheet
- Oracle EBS GL Period Close Checklist
- Oracle EBS AP Invoice Interface Template
Keep exploring
Free tools
- Oracle EBS Procure-to-Pay (P2P) SQL Generator: PO to Receipt to Invoice to PaymentGenerates a detail query tracing PO distributions through receipts, AP invoice distributions and payments, a non-duplicating summary per distribution, and a supplier statement.
- Oracle EBS Average Cost Receipt and PPV CalculatorSee how a PO receipt moves weighted average cost, and what the same receipt would book as PPV under standard costing.
- Oracle EBS SQL Query Generator for Items and WIP JobsBuild ready-to-run SELECT statements over MTL_SYSTEM_ITEMS_B, WIP_DISCRETE_JOBS and on-hand quantity tables.
ERP fixes and how-tos
- Oracle EBS Query for a Vendor Extract ReportSQL for an Oracle EBS R12 supplier extract: AP_SUPPLIERS, AP_SUPPLIER_SITES_ALL, contacts and bank accounts via IBY tables, with joins and security notes.
- Oracle EBS Standard Reports by Module and Sample XML for BI PublisherHow to find and run Oracle EBS standard reports by module, and how to get sample XML data to design a BI Publisher template for an EBS report.
- Oracle EBS REST API: Integrated SOA Gateway and PL/SQL APIsOracle EBS REST and SOAP APIs through Integrated SOA Gateway: find APIs in the Integration Repository, deploy, grant access and call PL/SQL public APIs.
Runs with your ERP
- Esker Order Management and Oracle E-Business SuiteHow Esker captures customer POs from email, fax and PDF and creates sales orders in Oracle EBS: integration, data flows, setup, pitfalls and a private AI layer.
- ProShip and Oracle E-Business Suite: multi-carrier shippingHow ProShip rates shipments and prints carrier labels and documents from Oracle EBS shipping data: integration, data flows, setup, pitfalls and AI.
- ShipConsole with Oracle E-Business Suite: Multi-Carrier ShippingShipConsole adds multi-carrier parcel and LTL shipping, rate shopping, hazmat and customs documents to Oracle EBS and JD Edwards. Flows, setup and pitfalls.
AI on your ERP
- AI for Oracle EBS Order Management, From Booking to InvoicePrivate AI for Oracle EBS Order Management: order holds, ATP, pick release, shipping and AutoInvoice questions answered from live data, no cloud AI needed.
- AI for Oracle E-Business Suite, Without Leaving On-PremHosting Oracle EBS 12.2 on-prem or in a private cloud? Add a private LLM over concurrent programs, interface tables and AP/PO data without moving to Fusion.
Integrations
- How to use ChatGPT with Oracle E-Business SuiteUsing ChatGPT with Oracle E-Business Suite: export vs live access, custom GPT actions over ISG REST, enterprise data controls and when to keep data on-prem.
- How to connect Claude to Oracle E-Business SuiteConnect Claude to Oracle E-Business Suite via MCP, the Anthropic API, AWS Bedrock or Vertex, and know when an on-prem open-weight model is the better fit.