Minimum Stock and Reorder Control in SAP Business One: 3 Essential SQL Queries - featured image

Publications

Minimum Stock and Reorder Control in SAP Business One: 3 Essential SQL Queries

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

In SAP Business One, minimum stock control and reorder points represents one of the most critical challenges for companies with inventory operations. Every time a product hits zero while demand is active, the company not only loses a sale: it damages its reputation, halts a production line or triggers emergency costs nobody budgeted. Yet very few IT leaders and operations managers take advantage of the capabilities of SAP Business One minimum stock reorder through direct SQL queries to get ahead of these stockouts.

This tutorial gives you three ready-to-use SQL queries — with versions for SQL Server y SAP HANA — that turn inventory data into actionable early warnings. You do not need Crystal Reports or an extra module: just the SAP B1 Query Manager and the knowledge to interpret the results.

SAP Business One minimum stock reorder - inventory control in the warehouse
Minimum stock control and reorder points are key to operational continuity.

Why manual stock control fails in growing companies

When a company handles fewer than 200 SKUs, manual inventory tracking may be enough. However, as the catalog, the warehouses and the sales channels grow, that model collapses. Consequently, purchasing teams react late, plant managers halt production runs and salespeople promise lead times that cannot be met.

SAP Business One stores all the information needed to avoid this situation in two key tables: OITM (item master) and OITW (stock by warehouse). These tables hold the fields for minimum stock (MinStock), maximum stock (MaxStock), committed (IsCommited), on order (OnOrder) and on hand (OnHand). Therefore, with a well-built query you can know exactly which item needs replenishing today, in which warehouse and in what quantity.

The problem is that many SAP B1 implementations do not configure the values of MinStock and MaxStock correctly. As a result, even though the system has the capability, the reports do not reflect reality. Consequently, this article also covers how to validate and maintain that configuration.

Prerequisites before running the queries

For these queries to work properly, first verify that inventory items have the minimum and maximum stock fields configured. Go to Inventory → Item Master Data → Planning Data tab. At the warehouse level, each warehouse must have values defined in:

  • Minimum stock: the level at which a purchase order should be triggered.
  • Maximum stock: the level you want to reach with each replenishment.
  • Order quantity: standard purchase quantity from the supplier.

Also, make sure you have access to the Query Manager in SAP B1 (Tools → Queries → Query Manager menu). If you do not have access, request it from your SAP administrator. You can then create and save these queries for recurring team use.

Query 1: Items below minimum stock in SAP Business One

This is the most important query: it identifies in real time every item whose available stock (net of committed and plus what is already on order) has fallen below the minimum configured in the system. This way, the purchasing team gets a prioritized list for immediate action.

SQL Server

-- Query 1 SQL Server: Artículos bajo stock mínimo por almacén
SELECT 
    T0.ItemCode          AS 'Código',
    T0.ItemName          AS 'Descripción',
    T1.WhsCode           AS 'Almacén',
    T1.OnHand            AS 'En Mano',
    T1.IsCommited        AS 'Comprometido',
    T1.OnOrder           AS 'En Pedido',
    (T1.OnHand - T1.IsCommited) AS 'Disponible Real',
    (T1.OnHand - T1.IsCommited + T1.OnOrder) AS 'Stock Proyectado',
    T1.MinStock          AS 'Stock Mínimo',
    T1.MaxStock          AS 'Stock Máximo',
    CASE 
        WHEN (T1.OnHand - T1.IsCommited + T1.OnOrder) <= 0 
        THEN 'QUIEBRE'
        WHEN (T1.OnHand - T1.IsCommited + T1.OnOrder) <= T1.MinStock 
        THEN 'REORDENAR'
        ELSE 'OK' 
    END AS 'Estado',
    T0.SuppCatNum        AS 'Código Proveedor',
    T2.CardName          AS 'Proveedor Principal'
FROM OITM T0
INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
LEFT  JOIN OCRD T2 ON T0.CardCode  = T2.CardCode
WHERE T0.InvntItem = 'Y' 
  AND T0.Canceled  = 'N'
  AND T1.MinStock  > 0
  AND (T1.OnHand - T1.IsCommited + T1.OnOrder) <= T1.MinStock
ORDER BY 
    CASE WHEN (T1.OnHand - T1.IsCommited + T1.OnOrder) <= 0 THEN 0 ELSE 1 END,
    T0.ItemCode, T1.WhsCode

SAP HANA

-- Query 1 SAP HANA: Artículos bajo stock mínimo por almacén
SELECT 
    T0."ItemCode"        AS "Código",
    T0."ItemName"        AS "Descripción",
    T1."WhsCode"         AS "Almacén",
    T1."OnHand"          AS "En Mano",
    T1."IsCommited"      AS "Comprometido",
    T1."OnOrder"         AS "En Pedido",
    (T1."OnHand" - T1."IsCommited")              AS "Disponible Real",
    (T1."OnHand" - T1."IsCommited" + T1."OnOrder") AS "Stock Proyectado",
    T1."MinStock"        AS "Stock Mínimo",
    T1."MaxStock"        AS "Stock Máximo",
    CASE 
        WHEN (T1."OnHand" - T1."IsCommited" + T1."OnOrder") <= 0 
        THEN 'QUIEBRE'
        WHEN (T1."OnHand" - T1."IsCommited" + T1."OnOrder") <= T1."MinStock" 
        THEN 'REORDENAR'
        ELSE 'OK' 
    END AS "Estado",
    T0."SuppCatNum"      AS "Código Proveedor",
    T2."CardName"        AS "Proveedor Principal"
FROM OITM T0
INNER JOIN OITW T1 ON T0."ItemCode" = T1."ItemCode"
LEFT  JOIN OCRD T2 ON T0."CardCode" = T2."CardCode"
WHERE T0."InvntItem" = 'Y' 
  AND T0."Canceled"  = 'N'
  AND T1."MinStock"  > 0
  AND (T1."OnHand" - T1."IsCommited" + T1."OnOrder") <= T1."MinStock"
ORDER BY 
    CASE WHEN (T1."OnHand" - T1."IsCommited" + T1."OnOrder") <= 0 THEN 0 ELSE 1 END,
    T0."ItemCode", T1."WhsCode"
LIMIT 500

This query automatically prioritizes the items in total stockout (projected stock ≤ 0) over those merely at reorder level. It also includes the main supplier from the item master, which lets the purchasing team act immediately without checking other screens.

Query 2: Reorder Report with Suggested Purchase Quantity

The first query detects the problem; the second, however, tells you what to do. It calculates the optimal quantity to buy to bring each item up to its configured maximum stock, net of what is already in transit (open purchase orders recorded in SAP B1). As a result, the purchasing team can raise orders grounded in data, not in intuition.

SAP Business One minimum stock reorder - inventory report in the warehouse
An accurate reorder report removes the uncertainty from the purchasing process.

SQL Server

-- Query 2 SQL Server: Reporte de Reorden con cantidad sugerida
SELECT 
    T0.ItemCode          AS 'Código',
    T0.ItemName          AS 'Descripción',
    T1.WhsCode           AS 'Almacén',
    T1.OnHand            AS 'En Mano',
    T1.IsCommited        AS 'Comprometido',
    T1.OnOrder           AS 'En Pedido (OC abiertas)',
    T1.MinStock          AS 'Stock Mínimo',
    T1.MaxStock          AS 'Stock Máximo',
    -- Disponible neto considerando comprometidos y pedidos en curso
    (T1.OnHand - T1.IsCommited + T1.OnOrder) AS 'Stock Efectivo',
    -- Cantidad sugerida para llegar al máximo
    CASE 
        WHEN (T1.MaxStock - T1.OnHand - T1.OnOrder) > 0 
        THEN (T1.MaxStock - T1.OnHand - T1.OnOrder)
        ELSE 0 
    END AS 'Cantidad a Comprar',
    -- Precio de compra de referencia del maestro
    T0.LastPurPrc        AS 'Último Precio Compra',
    -- Costo estimado del reabastecimiento
    CASE 
        WHEN (T1.MaxStock - T1.OnHand - T1.OnOrder) > 0 
        THEN ISNULL(T0.LastPurPrc, 0) * (T1.MaxStock - T1.OnHand - T1.OnOrder)
        ELSE 0 
    END AS 'Costo Est. Reabastecimiento',
    T2.CardName          AS 'Proveedor',
    T0.LeadTime          AS 'Días Lead Time'
FROM OITM T0
INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
LEFT  JOIN OCRD T2 ON T0.CardCode  = T2.CardCode
WHERE T0.InvntItem = 'Y' 
  AND T0.Canceled  = 'N'
  AND T1.MinStock  > 0
  AND (T1.OnHand - T1.IsCommited + T1.OnOrder) <= T1.MinStock
ORDER BY 
    ISNULL(T0.LastPurPrc,0) * 
    CASE WHEN (T1.MaxStock - T1.OnHand - T1.OnOrder) > 0 
         THEN (T1.MaxStock - T1.OnHand - T1.OnOrder) 
         ELSE 0 END DESC

SAP HANA

-- Query 2 SAP HANA: Reporte de Reorden con cantidad sugerida
SELECT 
    T0."ItemCode"        AS "Código",
    T0."ItemName"        AS "Descripción",
    T1."WhsCode"         AS "Almacén",
    T1."OnHand"          AS "En Mano",
    T1."IsCommited"      AS "Comprometido",
    T1."OnOrder"         AS "En Pedido (OC abiertas)",
    T1."MinStock"        AS "Stock Mínimo",
    T1."MaxStock"        AS "Stock Máximo",
    (T1."OnHand" - T1."IsCommited" + T1."OnOrder") AS "Stock Efectivo",
    CASE 
        WHEN (T1."MaxStock" - T1."OnHand" - T1."OnOrder") > 0 
        THEN (T1."MaxStock" - T1."OnHand" - T1."OnOrder")
        ELSE 0 
    END AS "Cantidad a Comprar",
    T0."LastPurPrc"      AS "Último Precio Compra",
    CASE 
        WHEN (T1."MaxStock" - T1."OnHand" - T1."OnOrder") > 0 
        THEN IFNULL(T0."LastPurPrc", 0) * (T1."MaxStock" - T1."OnHand" - T1."OnOrder")
        ELSE 0 
    END AS "Costo Est. Reabastecimiento",
    T2."CardName"        AS "Proveedor",
    T0."LeadTime"        AS "Días Lead Time"
FROM OITM T0
INNER JOIN OITW T1 ON T0."ItemCode" = T1."ItemCode"
LEFT  JOIN OCRD T2 ON T0."CardCode" = T2."CardCode"
WHERE T0."InvntItem" = 'Y' 
  AND T0."Canceled"  = 'N'
  AND T1."MinStock"  > 0
  AND (T1."OnHand" - T1."IsCommited" + T1."OnOrder") <= T1."MinStock"
ORDER BY 
    IFNULL(T0."LastPurPrc", 0) * 
    CASE WHEN (T1."MaxStock" - T1."OnHand" - T1."OnOrder") > 0 
         THEN (T1."MaxStock" - T1."OnHand" - T1."OnOrder") 
         ELSE 0 END DESC
LIMIT 500

Sorting by estimated replenishment cost, descending, is a deliberate strategic decision. This way, the purchasing manager sees first the items that represent the largest investment and the greatest operational impact, prioritizing with no extra effort.

Query 3: Stock Projection with Average Consumption of the Last 90 Days

The two previous queries work with static inventory data. This third one, however, adds dynamic intelligence: it calculates each item's average daily consumption over the last 90 days (based on sales invoices) and projects how many days of stock remain before the stockout point. As a result, the purchasing team can anticipate precisely instead of merely reacting.

SQL Server

-- Query 3 SQL Server: Proyección de días de stock disponible
SELECT 
    T0.ItemCode,
    T0.ItemName          AS 'Descripción',
    T1.WhsCode           AS 'Almacén',
    (T1.OnHand - T1.IsCommited) AS 'Disponible',
    T1.MinStock          AS 'Stock Mínimo',
    -- Consumo total en 90 días desde facturas de venta
    ISNULL(VTA.Consumo90d, 0) AS 'Consumido 90 días',
    -- Consumo diario promedio
    ISNULL(VTA.Consumo90d, 0) / 90.0 AS 'Consumo Diario Prom.',
    -- Días de stock disponible antes del quiebre
    CASE 
        WHEN ISNULL(VTA.Consumo90d, 0) = 0 THEN 999
        ELSE CAST((T1.OnHand - T1.IsCommited) / (VTA.Consumo90d / 90.0) AS INT)
    END AS 'Días de Stock',
    -- Fecha estimada de quiebre
    CASE 
        WHEN ISNULL(VTA.Consumo90d, 0) = 0 THEN NULL
        ELSE DATEADD(DAY, 
            CAST((T1.OnHand - T1.IsCommited) / (VTA.Consumo90d / 90.0) AS INT),
            GETDATE())
    END AS 'Fecha Estimada Quiebre',
    T0.LeadTime          AS 'Lead Time (días)'
FROM OITM T0
INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
LEFT JOIN (
    SELECT 
        T2.ItemCode,
        T2.WhsCode,
        SUM(T2.Quantity) AS Consumo90d
    FROM INV1 T2
    INNER JOIN OINV T3 ON T2.DocEntry = T3.DocEntry
    WHERE T3.DocStatus = 'C'
      AND T3.DocDate >= DATEADD(DAY, -90, GETDATE())
      AND T3.CANCELED = 'N'
    GROUP BY T2.ItemCode, T2.WhsCode
) VTA ON T0.ItemCode = VTA.ItemCode AND T1.WhsCode = VTA.WhsCode
WHERE T0.InvntItem = 'Y' 
  AND T0.Canceled  = 'N'
  AND T1.OnHand    > 0
  AND ISNULL(VTA.Consumo90d, 0) > 0
ORDER BY 
    CASE 
        WHEN ISNULL(VTA.Consumo90d, 0) = 0 THEN 999
        ELSE CAST((T1.OnHand - T1.IsCommited) / (VTA.Consumo90d / 90.0) AS INT)
    END ASC

SAP HANA

-- Query 3 SAP HANA: Proyección de días de stock disponible
SELECT 
    T0."ItemCode",
    T0."ItemName"        AS "Descripción",
    T1."WhsCode"         AS "Almacén",
    (T1."OnHand" - T1."IsCommited") AS "Disponible",
    T1."MinStock"        AS "Stock Mínimo",
    IFNULL(VTA."Consumo90d", 0)   AS "Consumido 90 días",
    IFNULL(VTA."Consumo90d", 0) / 90.0 AS "Consumo Diario Prom.",
    CASE 
        WHEN IFNULL(VTA."Consumo90d", 0) = 0 THEN 999
        ELSE CAST((T1."OnHand" - T1."IsCommited") / (VTA."Consumo90d" / 90.0) AS INT)
    END AS "Días de Stock",
    CASE 
        WHEN IFNULL(VTA."Consumo90d", 0) = 0 THEN NULL
        ELSE ADD_DAYS(CURRENT_DATE, 
            CAST((T1."OnHand" - T1."IsCommited") / (VTA."Consumo90d" / 90.0) AS INT))
    END AS "Fecha Estimada Quiebre",
    T0."LeadTime"        AS "Lead Time (días)"
FROM OITM T0
INNER JOIN OITW T1 ON T0."ItemCode" = T1."ItemCode"
LEFT JOIN (
    SELECT 
        T2."ItemCode",
        T2."WhsCode",
        SUM(T2."Quantity") AS "Consumo90d"
    FROM INV1 T2
    INNER JOIN OINV T3 ON T2."DocEntry" = T3."DocEntry"
    WHERE T3."DocStatus" = 'C'
      AND T3."DocDate" >= ADD_DAYS(CURRENT_DATE, -90)
      AND T3."CANCELED" = 'N'
    GROUP BY T2."ItemCode", T2."WhsCode"
) VTA ON T0."ItemCode" = VTA."ItemCode" AND T1."WhsCode" = VTA."WhsCode"
WHERE T0."InvntItem" = 'Y' 
  AND T0."Canceled"  = 'N'
  AND T1."OnHand"    > 0
  AND IFNULL(VTA."Consumo90d", 0) > 0
ORDER BY 
    CASE 
        WHEN IFNULL(VTA."Consumo90d", 0) = 0 THEN 999
        ELSE CAST((T1."OnHand" - T1."IsCommited") / (VTA."Consumo90d" / 90.0) AS INT)
    END ASC
LIMIT 500

The column Estimated Stockout Date is what turns this report into a management tool. For example, if an item with a 15-day lead time will run out in 10 days, it is already too late to act. However, if the system flags it 25 days ahead, there is room to negotiate with the supplier, adjust prices or communicate constraints to the sales team.

Variations and specific use cases

These three queries are the foundation; however, there are useful variations depending on the type of company:

For companies with multiple warehouses: Add a filter AND T1.WhsCode IN ('01','02','05') to focus the analysis on the main production warehouses and exclude transit or scrap locations.

For companies with seasonality: Instead of 90 days, change the Query 3 analysis period to the last 30 days in high season, or to the last 365 days as an annual reference. This way, the consumption model better reflects the real demand of the relevant period.

For control by item group: Add the table OITB (item groups) with a JOIN on ItmsGrpCod and filter by specific categories — for example, only raw materials or only critical spare parts.

For integration with automatic alerts: Save Query 2 in the SAP B1 Query Manager and set it as the basis of a Formatted Search that updates a user field in the item master. Consequently, each item shows its reorder status directly on its inventory record.

Best practices and common mistakes when configuring minimum stock in SAP B1

SAP Business One minimum stock reorder - data analysis for inventory decisions
SAP B1 data lets you anticipate stockouts with analytical precision.

After implementing these queries with several industrial companies, these are the most common mistakes that hold the results back:

Mistake 1: MinStock = 0 on most items. If the field MinStock is zero, the queries will detect nothing. The fix is a mass load of minimum stock through DTW (Data Transfer Workbench) using consumption history. A valid first calculation is to set MinStock as average monthly consumption multiplied by the supplier lead time plus a 20% buffer.

Mistake 2: Confusing available with on hand. The field OnHand is not the real available stock. Available stock is OnHand - IsCommited. However, for reorder point purposes what matters is effective stock: OnHand - IsCommited + OnOrder, since open purchase orders in SAP B1 are reflected in OnOrder.

Mistake 3: Not updating Lead Time in the item master. Query 3 uses the field LeadTime from OITM as a reference. If this field is empty or outdated, the urgency calculation loses its value. Therefore, keeping the lead time updated for each supplier is as critical as the minimum stock itself.

Mistake 4: Running the queries without filtering obsolete items. Discontinued items, or items with no movement for more than 12 months, distort the analysis. Always add the filter AND T0.CANCELED = 'N' and consider adding a condition on the last movement date.

How to save and schedule these queries in SAP Business One

Once the queries are validated, the next step is to institutionalize them in your organization. To save in the Query Manager, follow this path: Tools → Queries → Query Manager → New Query. Give it a descriptive name such as «Minimum Stock Control – Daily» and save it in a category accessible to the purchasing team.

You can also configure an Automatic alert in SAP B1 (Tools → Alerts → New Alert) linked to a query that counts the items in stockout status. For example, if the count is greater than zero, the system can send an automatic email to the purchasing owner every morning. This way, the team does not need to run the report manually: the system works for them.

Official SAP resources to learn more

To go deeper into the table structure and the official documentation, these are the most relevant resources:

  • SAP Business One SDK Help Center: Complete documentation of the OITM and OITW tables with all their fields and official descriptions.
  • SAP Community — SAP Business One (community.sap.com): Active forum with thousands of queries shared by implementers worldwide.
  • SAP Help Portal (help.sap.com): User manuals for inventory management and requirements planning in SAP B1.
  • SAP Learning Hub: Official SAP courses on inventory management and planning in SAP Business One.

Conclusion: from data to real control of your inventory

The SAP Business One minimum stock reorder is not an optional system function: it is a capability that, properly configured and queried with the right SQL, can eliminate up to 80% of stockouts in a company. However, the ERP does not act on its own. It needs clean data, up-to-date parameters and a team that understands how to read the reports the system produces.

The three queries in this article give you the starting point. First, install them in your Query Manager this week. Next, check how many items have MinStock configured. However, the real work begins when those results trigger a conversation between IT, purchasing and operations about the parameters that truly reflect your operational reality.

If you need support implementing an inventory alert system in SAP Business One or configuring the planning parameters properly, write to us and let's talk about your specific case. Every company has its own supply chain and deserves a control model that respects it.

Most Read

QlikSense Hierarchy: parent-child chart of accounts expanded by levels
QlikSense Hierarchy: the Chart of Accounts That Doesn't Add Up
QlikSense Sum TOTAL: share of each family over the total
QlikSense Sum TOTAL: the Percentage That Changes When You Filter
SAP Business One Inventory Revaluation - featured image of the tutorial
SAP Business One Inventory Revaluation: Fix Wrongly Loaded Costs
Empty chamber with wooden benches: the counterweight that required being present to be used
The Veto You Had to Say in Person: Your Decisions With No Counterweight
SAP Business One customizations - featured image of the pre-upgrade audit tutorial
SAP Business One Customizations: Pre-Upgrade Audit
SAP Business One Customer Concentration - featured image of the tutorial
SAP Business One Customer Concentration: Measure Your Risk with SQL

RELATED ARTICLES