OBTQ table in SAP Business One (Batch Number Quantities (per warehouse))

OBTQ is the SAP Business One table that holds the quantity of each batch per warehouse: one row per batch and warehouse, with Quantity, CommitQty and CountQty. It points to the batch master OBTN through MdAbsEntry (or ItemCode plus SysNumber) and to the warehouse through WhsCode.

OBTQ key fields

FieldWhat it holds
AbsEntryInternal key of the row.
MdAbsEntryBatch master key. Joins to OBTN.AbsEntry.
ItemCodeItem. Joins to OITM.ItemCode.
SysNumberSystem number of the batch. With ItemCode it joins to OBTN.
WhsCodeWarehouse. Joins to OWHS.WhsCode.
QuantityQuantity of the batch in the warehouse.
CommitQtyCommitted quantity.
CountQtyCounted quantity.

How OBTQ relates to other tables

OBTQ is the quantity layer under OBTN. One batch can be split across several warehouses, so it has one OBTQ row per warehouse. Join OBTQ.MdAbsEntry = OBTN.AbsEntry for the batch number and dates, and OBTQ.WhsCode = OWHS.WhsCode for the warehouse.

Common joins

  • OBTQ T0 INNER JOIN OBTN T1 ON T1.AbsEntry = T0.MdAbsEntry (batch number and dates)
  • OBTQ T0 INNER JOIN OWHS T2 ON T2.WhsCode = T0.WhsCode (warehouse)
  • OBTQ T0 INNER JOIN OITM T3 ON T3.ItemCode = T0.ItemCode (item master)

When you use the OBTQ table

Use OBTQ for stock by batch and warehouse, free batch quantity (Quantity minus CommitQty) before picking, and to check that batch totals per warehouse agree with the item stock.

Example query: batch stock per warehouse with committed and free quantity

SQL Server

SELECT T0.ItemCode, T1.DistNumber AS BatchNumber, T0.WhsCode, T0.Quantity,
  T0.CommitQty, T0.Quantity - T0.CommitQty AS FreeQty
FROM OBTQ T0
INNER JOIN OBTN T1 ON T1.AbsEntry = T0.MdAbsEntry
WHERE T0.Quantity > 0
ORDER BY T0.ItemCode, T1.DistNumber, T0.WhsCode

SAP HANA (column names in double quotes)

SELECT T0."ItemCode", T1."DistNumber" AS "BatchNumber", T0."WhsCode", T0."Quantity",
  T0."CommitQty", T0."Quantity" - T0."CommitQty" AS "FreeQty"
FROM OBTQ T0
INNER JOIN OBTN T1 ON T1."AbsEntry" = T0."MdAbsEntry"
WHERE T0."Quantity" > 0
ORDER BY T0."ItemCode", T1."DistNumber", T0."WhsCode"

Paste either version in Tools → Queries → Query Generator. Need the other dialect for your own query? Use the SQL to HANA converter.

Common pitfall: Summing OBTQ without the warehouse

One batch can have rows in several warehouses, and rows can have Quantity 0. Filter Quantity > 0 and keep WhsCode in the GROUP BY, or a batch looks bigger or smaller than it is in the warehouse you pick from. See Batches expiring soon query.

Ready-made queries that use OBTQ

Questions about the OBTQ table

What is the difference between OBTN and OBTQ?

OBTN is the batch master (batch number, dates, status). OBTQ holds the quantity of each batch per warehouse.

How do I join OBTQ to OBTN?

On OBTQ.MdAbsEntry = OBTN.AbsEntry, or on ItemCode and SysNumber together.

How do I get the free quantity of a batch?

Quantity minus CommitQty in OBTQ, per warehouse.

Related tables

OBTN (Batch Numbers (master data)) · OWHS (Warehouses) · OITW (Item stock per warehouse) · search all SAP Business One tables

Sources: SAP Business One documentation and SDK (DI API database tables reference), SAP Help Portal.

Ready to get started?

Tell us what you need. You get a clear technical answer, a fixed scope and a price, usually within 24 hours.