SAP Business One Production Component Shortage SQL Generator
Planners in Business One often ask the same question: which released production orders cannot be completed because a component is short? This generator writes the query over production orders, their component rows and stock by warehouse.
Fill in
R = Released, P = Planned. L = Closed, C = Canceled.
Shortage query (SQL Server syntax)
SELECT T0.DocNum, T0.ItemCode AS ParentItem, T0.DueDate, T1.ItemCode AS Component, T1.wareHouse AS Whs, T1.PlannedQty, T1.IssuedQty, (T1.PlannedQty - T1.IssuedQty) AS OpenQty, T2.OnHand, T2.IsCommited AS Committed, T2.OnOrder, (T2.OnHand - T2.IsCommited + T2.OnOrder) AS Available FROM OWOR T0 INNER JOIN WOR1 T1 ON T1.DocEntry = T0.DocEntry LEFT JOIN OITW T2 ON T2.ItemCode = T1.ItemCode AND T2.WhsCode = T1.wareHouse WHERE T0.Status = 'R' AND T0.DueDate <= '2026-11-30' AND T1.ItemType = 4 AND T1.wareHouse = '01' AND (T1.PlannedQty - T1.IssuedQty) > ISNULL(T2.OnHand, 0) ORDER BY T0.DueDate, T0.DocNum;
WOR1.ItemType 4 selects item components (resources and text lines have other values). The query compares open quantity per order with on-hand quantity and ignores competition between orders for the same stock, so for a true multi-order shortage sum open quantity by component first. On SAP HANA, wrap identifiers in double quotes and replace ISNULL with IFNULL. Test in Query Manager before saving.
Plan-to-produce reporting for Business One
Optional: a short call about shortage and capacity reporting for your B1 plant.
Optional. The tool and every export work without this. No spam.
How the query works
OWOR is the production order header and WOR1 holds its rows. For each component row the query computes open quantity as planned minus issued, joins stock for the same item and warehouse from OITW, and keeps rows where the open quantity exceeds what is on hand. It also shows committed and on-order quantities so a planner can see whether a purchase order is already covering the gap.
- Status R is released, P planned, L closed, C canceled
- ItemType 4 filters out resources and text lines
- Available = on hand - committed + on order
- Filter on the due date to focus on the next weeks
Reading the output
A row with OpenQty above OnHand is a hard shortage at that warehouse today. If Available is still positive because of purchase orders, check the vendor due date against the production order due date. Sort by due date to put the most urgent first, and export to Excel to send a buyer the list.
Limits to know
The same stock may be needed by several orders, so a row-by-row comparison can understate a shortage. The standard MRP wizard and recommendation report handle netting across orders, and are the better source when MRP is set up. Use this query as a quick shop-floor check and a starting point for a custom report.
Frequently Asked Questions
Can I run this in Query Manager?
Yes on SQL Server editions, paste it into a new query in Query Manager and execute. On HANA editions the syntax needs double-quoted identifiers and IFNULL instead of ISNULL, otherwise it will fail to parse.
Why are phantom items missing?
Phantom bills are exploded into their own components when the production order is created, so you see the lower-level items on WOR1 rather than the phantom parent. Check the BOM type on the product tree if rows look different from expectation.
Does it handle backflush components?
Backflush components are issued at receipt, so IssuedQty stays zero until then. The query would show them as open. Add a filter on the issue method column of WOR1 if you want to exclude them.
Is this the same as the MRP recommendation?
No. MRP nets all demand and supply by time bucket and proposes orders. This query is a snapshot of order component rows against current warehouse stock.
If planners would rather ask which orders are at risk in plain language and get the query shown back, Netray can connect that to your Business One data, read-only.
Related Tools
SAP Business One Database Tables Reference
Searchable lookup of the core SAP Business One tables, with the matching row table and what each one stores.
SAPSAP Business One Document Object Type Codes
Lookup of ObjType numbers used in B1 queries, UDO links and approval templates, with header and row tables.
Developer ToolsSAP Business One Service Layer Request Builder
Fill in host, company and item details and get ready-to-paste Service Layer requests for login, item query, sales order and production order.
SAPSAP Business One Go-Live Cutover Checklist
A cutover checklist for taking a Business One company live: freeze, balances, stock counts, users, integrations and hypercare.
More SAP tools
See all- SAP Business One Production Order Checklist
- SAP B1 Item Master Import Template (DTW)
- SAP B1 MRP Setup Readiness Assessment
- SAP B1 Implementation Cost Calculator
- SAP Business One Go-Live Readiness Checklist
- SAP Business One Implementation Project Charter Template
- SAP Business One BOM Cost Rollup Worksheet
- SAP Business One Cycle Count Variance Worksheet
- SAP Business One License and 5-Year TCO Calculator
New to SAP Business One? Start with the SAP Business One guide and toolkit.
Keep exploring
Free tools
- SAP Business One Production Order ChecklistA step-by-step checklist for creating, releasing, issuing to, receiving from and closing a production order in SAP Business One.
- Component Shortage SQL Query Generator (Open Demand vs Supply)Generate a SQL query that compares open demand against on-hand and inbound supply and returns the shortage list for buyers.
- SAP Business One Private AI Layer Blueprint GeneratorFill in your version, database, hosting and use cases to get an architecture plan for adding a private, on-prem AI assistant to SAP Business One, with components, security controls and a three-phase rollout.
ERP fixes and how-tos
- SAP Business One Query: Released Production Orders with Component ShortagesReady-to-run SAP Business One queries on OWOR, WOR1 and OITW to list released production orders with missing components, for SQL Server and HANA.
- SAP Business One production planning: MRP, production orders, cost and variancesSAP Business One production planning end to end: MRP, planned to released orders, cost rollup, variance reporting and when you need a manufacturing add-on.
- Production standard cost in SAP Business One: how it works and where it stopsHow standard cost works for production orders in SAP Business One: valuation method, issue and receipt values, variances at close and process limits.
Runs with your ERP
- CompuTec WMS and SAP Business One: Mobile Warehouse TransactionsHow CompuTec WMS posts goods receipts, pick lists, transfers and production receipts into SAP Business One, with setup steps, pitfalls and a private AI layer.
- Spreadsheet Server with SAP Business One: live Excel reporting on inventory, sales and costHow insightsoftware Spreadsheet Server gives Excel live drill-down on SAP Business One inventory, sales and production cost data, with setup and pitfalls.
- Beas Manufacturing with SAP Business OneHow Boyum's Beas Manufacturing adds planning, capacity scheduling, quality control and shop floor control to SAP Business One, plus setup and pitfalls.
AI on your ERP
- AI on SAP Business One for Electronics Manufacturers: BOMs, Shortages and TraceabilityPrivate AI on SAP Business One for electronics makers: multi-level BOM questions, component shortages, lot and serial traceability, RoHS and obsolescence checks.
- AI for SAP Business One Inventory: Stock, Batches, Bins and ValuationPrivate AI over SAP Business One inventory: OITW stock, batches, serials, bins and valuation. Answers grounded in live data via Service Layer or SQL views.
Integrations
- How to connect Power BI to SAP Business OneConnect Power BI to SAP Business One: SQL Server or HANA direct, Service Layer OData, gateway setup, key manufacturing dashboards and natural-language Q&A.
- How to add a mobile app to SAP Business OneBuild or choose a mobile app for SAP Business One: barcode scanning, inventory moves, pick lists, approvals, Service Layer access, offline sync and security.