Stock by warehouse
On hand, committed, ordered and available quantity per item and warehouse.
Tool
SELECT T0.ItemCode, T1.ItemName, T0.WhsCode, T0.OnHand, T0.IsCommited, T0.OnOrder, T0.OnHand - T0.IsCommited + T0.OnOrder AS Available FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.OnHand <> 0 OR T0.IsCommited <> 0 OR T0.OnOrder <> 0 ORDER BY T0.ItemCode, T0.WhsCode
SELECT T0."ItemCode", T1."ItemName", T0."WhsCode", T0."OnHand", T0."IsCommited", T0."OnOrder", T0."OnHand" - T0."IsCommited" + T0."OnOrder" AS "Available" FROM OITW T0 INNER JOIN OITM T1 ON T0."ItemCode" = T1."ItemCode" WHERE T0."OnHand" <> 0 OR T0."IsCommited" <> 0 OR T0."OnOrder" <> 0 ORDER BY T0."ItemCode", T0."WhsCode"
What this query answers
A sales rep is on the phone with a customer and needs to know whether an item can be promised, and from which warehouse. This shows what is physically there, what is already promised to other orders and what is on the way.
You can also ask ChatGPT or Claude for stock levels straight from SAP Business One, through a read-only MCP server.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| ItemCode | ItemName | WhsCode | OnHand | IsCommited | OnOrder | Available |
|---|---|---|---|---|---|---|
| A00001 | Laser Printer 1420 | 01 | 120 | 30 | 50 | 140 |
| A00001 | Laser Printer 1420 | 02 | 40 | 0 | 0 | 40 |
| A00002 | Inkjet Printer 600 | 01 | 15 | 20 | 10 | 5 |
| A00003 | Toner Cartridge Color | 01 | 0 | 8 | 25 | 17 |
SQL Server vs SAP HANA
The SQL is unchanged except for quoting; the misspelled SAP column must be written "IsCommited" (one t) in double quotes. The OR conditions and the Available calculation work the same on HANA.
Variations
Only nettable warehouses
SQL Server
SELECT T0.ItemCode, T0.WhsCode, T0.OnHand, T0.IsCommited, T0.OnOrder, T0.OnHand - T0.IsCommited + T0.OnOrder AS Available FROM OITW T0 INNER JOIN OWHS T2 ON T0.WhsCode = T2.WhsCode WHERE T2.Nettable = 'Y' AND (T0.OnHand <> 0 OR T0.IsCommited <> 0 OR T0.OnOrder <> 0) ORDER BY T0.ItemCode, T0.WhsCode
SAP HANA
SELECT T0."ItemCode", T0."WhsCode", T0."OnHand", T0."IsCommited", T0."OnOrder", T0."OnHand" - T0."IsCommited" + T0."OnOrder" AS "Available" FROM OITW T0 INNER JOIN OWHS T2 ON T0."WhsCode" = T2."WhsCode" WHERE T2."Nettable" = 'Y' AND (T0."OnHand" <> 0 OR T0."IsCommited" <> 0 OR T0."OnOrder" <> 0) ORDER BY T0."ItemCode", T0."WhsCode"
Total per item across all warehouses
SQL Server
SELECT T0.ItemCode, T1.ItemName, SUM(T0.OnHand) AS OnHand, SUM(T0.IsCommited) AS IsCommited, SUM(T0.OnOrder) AS OnOrder, SUM(T0.OnHand - T0.IsCommited + T0.OnOrder) AS Available FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode GROUP BY T0.ItemCode, T1.ItemName ORDER BY T0.ItemCode
SAP HANA
SELECT T0."ItemCode", T1."ItemName", SUM(T0."OnHand") AS "OnHand", SUM(T0."IsCommited") AS "IsCommited", SUM(T0."OnOrder") AS "OnOrder", SUM(T0."OnHand" - T0."IsCommited" + T0."OnOrder") AS "Available" FROM OITW T0 INNER JOIN OITM T1 ON T0."ItemCode" = T1."ItemCode" GROUP BY T0."ItemCode", T1."ItemName" ORDER BY T0."ItemCode"
Hide zero-stock rows
SQL Server
SELECT T0.ItemCode, T1.ItemName, T0.WhsCode, T0.OnHand FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.OnHand > 0 ORDER BY T0.ItemCode, T0.WhsCode
SAP HANA
SELECT T0."ItemCode", T1."ItemName", T0."WhsCode", T0."OnHand" FROM OITW T0 INNER JOIN OITM T1 ON T0."ItemCode" = T1."ItemCode" WHERE T0."OnHand" > 0 ORDER BY T0."ItemCode", T0."WhsCode"
Bin-level stock (bin locations enabled)
SQL Server
SELECT T0.ItemCode, T1.WhsCode, T1.BinCode, T0.OnHandQty FROM OIBQ T0 INNER JOIN OBIN T1 ON T0.BinAbs = T1.AbsEntry WHERE T0.OnHandQty <> 0 ORDER BY T0.ItemCode, T1.BinCode
SAP HANA
SELECT T0."ItemCode", T1."WhsCode", T1."BinCode", T0."OnHandQty" FROM OIBQ T0 INNER JOIN OBIN T1 ON T0."BinAbs" = T1."AbsEntry" WHERE T0."OnHandQty" <> 0 ORDER BY T0."ItemCode", T1."BinCode"
Common errors and fixes
- Stock looks higher than what the warehouse can sell: Non-nettable warehouses (for example damaged goods or consignment) are included. Join OWHS and filter Nettable = 'Y'.
- Totals do not match OITM.OnHand per warehouse: OITM.OnHand is the total across all warehouses. The per-warehouse quantity is only in OITW.
- Invalid column name 'IsCommitted': SAP B1 spells the committed-quantity column IsCommited, with a single t. Use T0.IsCommited.
- Available looks too high for urgent orders: Available adds OnOrder, which includes purchase orders that may arrive weeks later. Use OnHand - IsCommited for what can ship today.
- Service items are not in the list: Only inventory items have rows in OITW. Non-stock and service items never appear, which is expected.
Need this report built into SAP Business One?
A saved query answers the question once. We build SAP Business One mobile apps: warehouse scanning, stock counts, sales orders and approvals on the Service Layer. Or hire a SAP Business One developer for the whole job, fixed price per phase.
Related queries
Table reference: OITW table (Item stock per warehouse) · OITM table (Items (item master data))
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 stock by warehouse 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 OITW, OITM 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.
