Production orders by status
Planned and released production orders with planned, completed and rejected quantity, due date and days late.
Tool
SELECT T0.DocNum, T0.ItemCode, T0.ProdName,
CASE T0.Status WHEN 'P' THEN 'Planned' WHEN 'R' THEN 'Released' END AS OrderStatus,
T0.PlannedQty, T0.CmpltQty, T0.RjctQty, T0.PlannedQty - T0.CmpltQty AS RemainingQty,
T0.Warehouse, T0.PostDate, T0.DueDate,
CASE WHEN T0.DueDate < GETDATE() THEN DATEDIFF(day, T0.DueDate, GETDATE()) ELSE 0 END AS DaysLate
FROM OWOR T0
WHERE T0.Status IN ('P', 'R')
ORDER BY T0.DueDate, T0.DocNum SELECT T0."DocNum", T0."ItemCode", T0."ProdName",
CASE T0."Status" WHEN 'P' THEN 'Planned' WHEN 'R' THEN 'Released' END AS "OrderStatus",
T0."PlannedQty", T0."CmpltQty", T0."RjctQty", T0."PlannedQty" - T0."CmpltQty" AS "RemainingQty",
T0."Warehouse", T0."PostDate", T0."DueDate",
CASE WHEN T0."DueDate" < CURRENT_TIMESTAMP THEN DAYS_BETWEEN(T0."DueDate", CURRENT_TIMESTAMP) ELSE 0 END AS "DaysLate"
FROM OWOR T0
WHERE T0."Status" IN ('P', 'R')
ORDER BY T0."DueDate", T0."DocNum" What this query answers
The production planner starts the day with one list of work that is not finished: which orders are planned or released, how much is done, how much is still to make and which are late. This returns every planned or released production order with planned, completed and rejected quantity, the due date and the days past due.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| DocNum | ItemCode | ProdName | OrderStatus | PlannedQty | CmpltQty | RjctQty | RemainingQty | Warehouse | PostDate | DueDate | DaysLate |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 301 | P10001 | Assembled Workstation | Released | 50 | 32 | 1 | 18 | 01 | 2026-10-28 | 2026-11-05 | 5 |
| 304 | P10003 | Cable Kit | Released | 400 | 400 | 0 | 0 | 01 | 2026-11-02 | 2026-11-08 | 2 |
| 307 | P10002 | Printer Stand | Planned | 120 | 0 | 0 | 120 | 02 | 2026-11-06 | 2026-11-14 | 0 |
| 309 | P10001 | Assembled Workstation | Planned | 25 | 0 | 0 | 25 | 01 | 2026-11-09 | 2026-11-20 | 0 |
SQL Server vs SAP HANA
CASE works the same on HANA. The DATEDIFF becomes DAYS_BETWEEN(T0."DueDate", CURRENT_TIMESTAMP), and the status values 'P' and 'R' stay as they are.
Common errors and fixes
- Closed orders do not show: That is by design. OWOR.Status is P (planned), R (released), L (closed) or C (cancelled); the query keeps P and R. Add 'L' to the IN list to see closed orders too.
- An order is finished but still released: Completed quantity can reach the planned quantity while the order stays released until someone closes it. RemainingQty = 0 marks those orders for closing.
Need this report built into SAP Business One?
A saved query answers the question once. We do custom SAP Business One development: add-ons, integrations and reports, from the database to the screen. Or hire a remote SAP Business One developer for the whole job, fixed price per phase.
Related queries
Table reference: OWOR table (Production Order (header))
Three steps, no signup
Copy the right version
Use the SQL Server tab for MS SQL databases and the HANA tab for SAP B1 on HANA.
Open Query Generator
In SAP Business One go to Tools → Queries → Query Generator, paste and click Execute.
Save and share
Click Save, pick a category and give the query a name. Your team can run it from Query Manager.
Questions about this tool
How do I run the production orders by status query in SAP Business One?
Copy the version that matches your database, open Tools → Queries → Query Generator, paste it in the SQL box and click Execute. Save it to reuse it later.
Which tables does this query use?
It reads OWOR from the standard SAP Business One schema. No user-defined fields are needed.
Can this be turned into a dashboard or alert?
Yes. We turn queries into Crystal reports, Excel reports that refresh themselves, SAP B1 alerts or WhatsApp messages for managers.
Built for SAP Business One teams
Need this inside SAP Business One?
We build add-ons, reports and integrations for SAP B1 on SQL Server and HANA. Tell us what you need and get a fixed price, usually within 24 hours.
