Prophet 21 Open Order and Backorder SQL Query Generator
Customer service teams want one list of open order lines and how long they have been waiting. This generator gives a clean starting SQL pattern for Prophet 21 that you finish with your own shipped quantity and status fields.
Fill in
Open order lines pattern
-- Pattern only. Confirm table and column names in your schema before use.
-- Read-only: use a reporting login.
SELECT TOP 300
h.order_no,
h.customer_id,
h.order_date,
DATEDIFF(day, h.order_date, GETDATE()) AS age_days,
l.line_no,
l.qty_ordered,
l.qty_canceled,
(l.qty_ordered - l.qty_canceled) AS qty_open_gross
FROM oe_hdr h
INNER JOIN oe_line l
ON l.order_no = h.order_no
WHERE h.order_date >= '2026-01-01'
AND h.customer_id = 100245
AND DATEDIFF(day, h.order_date, GETDATE()) >= 7
ORDER BY h.order_date, h.order_no, l.line_no;What to add before you rely on it
-- 1. Join your shipped or invoiced quantity source to subtract what has already shipped. -- 2. Add the completed or closed flag columns that your system uses on header and line. -- 3. Exclude quotes, returns and cancelled orders using your order type fields. -- 4. Add expected ship date if you want to separate past due from future.
This is a starting pattern. The names oe_hdr and oe_line are familiar from Prophet 21, but join keys, status flags and shipped-quantity columns vary by version and customization, so verify each one in your schema. Open quantity is not calculated fully here on purpose, because the shipped quantity source differs between installs. Run read-only.
Automate backorder follow-up
Optional: a conversation about a read-only agent that watches aging open lines and drafts follow-ups for a person to approve.
Optional. The tool and every export work without this. No spam.
How to use it
Enter the start date, a customer and a minimum age, then copy the pattern. The second block lists the pieces you must add: shipped quantity, closed flags, order type exclusions and expected ship date. Add them one at a time and compare to a known customer order on screen until the counts agree.
- Start with one customer and a short date range
- Compare to the standard order screen
- Add shipped quantity from your schema
- Exclude quotes, returns and cancelled orders
Why the pattern stops where it does
Open quantity is ordered minus canceled minus shipped. The shipped part comes from different places depending on how invoicing and pick tickets are configured, and a wrong guess produces plausible but false numbers. We prefer an honest partial query to an incorrect complete one.
Reading the result
Age in days uses the order date, not the promise date. A line that is old and still open is the first candidate to review with purchasing: is stock on a purchase order, is it a special order, or did the customer change the need? Sort by age and work from the oldest, then group by customer to find accounts with several stuck lines.
Common mistakes
The usual errors are counting canceled lines as open, including quotes, joining header and line on the wrong key so lines duplicate, and running the query without a date limit on the live server. Check row counts against the screen before you share a report.
Frequently Asked Questions
Why does the query not show shipped quantity?
Shipped quantity sits in different structures depending on configuration, such as pick ticket and invoice detail. Rather than guess, the pattern marks where to join your own source so the open quantity is correct.
Can I make this a backorder report?
Yes. After subtracting shipped quantity, filter to lines with open quantity greater than zero where available stock is below the open quantity. Use your system's availability rule for the stock side.
Will this slow the live system?
It can if run broadly. Keep a date range, filter by customer or location, limit rows, and prefer a reporting copy. Index advice should come from your DBA.
Is this valid for Eclipse?
No. It is a pattern for Prophet 21 on SQL Server. Eclipse is a different product with its own data access and reporting tools.
If backorder follow-up is manual in your branches, we can talk about a read-only agent that flags aging open lines from your own data.
Related Tools
Prophet 21 Inventory by Location SQL Generator
Builds a read-only SELECT for on-hand and allocated quantity by item and location in a Prophet 21 database.
Supply Chain & InventoryDistribution KPI Formula Reference
A searchable lookup of the standard KPI formulas a distributor tracks, with units, direction of good and common data traps.
Supply Chain & InventoryDistributor EDI X12 856 ASN Skeleton Generator
Fills an X12 856 skeleton with the segments a distributor typically sends: BSN, HL shipment, order and item loops.
EpicorProphet 21 Order to Cash Go-Live Test Checklist
A test script outline for the order-to-cash cycle in Prophet 21 before cutover, from quote to cash application.
More Epicor tools
See all- Prophet 21 Inventory Replenishment Calculator
- Prophet 21 Pricing Library Design Worksheet
- Prophet 21 Upgrade Checklist
- Prophet 21 Data Cleanup Checklist
- Prophet 21 Special Order Request Form Template
- Prophet 21 Vendor Return Authorization Request Template
- P21 Dead Stock Hold vs Liquidate Calculator
- P21 Price Matrix Multiplier and Margin Calculator
- Epicor Kinetic Job Status Reference