OBTN table in SAP Business One (Batch Numbers (master data))

OBTN is the SAP Business One table that stores batch number master data: one row per item and batch, with the batch number, manufacturing and expiry dates and status. It does not tell you where the stock is: quantities per warehouse are in OBTQ, joined on OBTQ.MdAbsEntry = OBTN.AbsEntry (or ItemCode plus SysNumber).

OBTN key fields

FieldWhat it holds
AbsEntryInternal key of the batch. OBTQ.MdAbsEntry points to it.
ItemCodeItem the batch belongs to. Joins to OITM.ItemCode.
SysNumberInternal batch number per item. Together with ItemCode it identifies the batch.
DistNumberThe batch number users see and print.
MnfSerialBatch attribute 1 (often the manufacturer batch).
LotNumberBatch attribute 2.
ExpDateExpiry date.
MnfDateManufacturing date.
InDateDate the batch was received.
Status0 = released, 1 = not accessible, 2 = locked.
OBTQ.WhsCodeWarehouse that holds the quantity.
OBTQ.QuantityQuantity of the batch in that warehouse.
OBTQ.CommitQtyQuantity committed to open documents.

How OBTN relates to other tables

OBTN is the batch master and OBTQ holds one row per batch and warehouse with Quantity, CommitQty and CountQty. Join them on OBTQ.MdAbsEntry = OBTN.AbsEntry, or on ItemCode and SysNumber together. Only items managed by batches have rows here. Bin locations, when used, add another level of quantities per bin.

Common joins

  • OBTN T0 INNER JOIN OBTQ T1 ON T1.MdAbsEntry = T0.AbsEntry (quantity per warehouse)
  • OBTN T0 INNER JOIN OBTQ T1 ON T1.ItemCode = T0.ItemCode AND T1.SysNumber = T0.SysNumber (same join, by item and batch)
  • OBTN T0 INNER JOIN OITM T2 ON T2.ItemCode = T0.ItemCode (item master)
  • OBTQ T1 INNER JOIN OWHS T3 ON T3.WhsCode = T1.WhsCode (warehouse)

When you use the OBTN table

Use OBTN with OBTQ for expiry reports (FEFO picking), stock by batch and warehouse, recall lists when a supplier batch is withdrawn, and to check that locked or not-accessible batches are not sold. Food, pharma and chemical companies run these reports every day.

Example query: stock by batch and warehouse with days to expiry

SQL Server

SELECT T0.ItemCode, T2.ItemName, T0.DistNumber AS BatchNumber, T0.ExpDate,
  T1.WhsCode, T1.Quantity, DATEDIFF(day, GETDATE(), T0.ExpDate) AS DaysLeft
FROM OBTN T0
INNER JOIN OBTQ T1 ON T1.MdAbsEntry = T0.AbsEntry
INNER JOIN OITM T2 ON T2.ItemCode = T0.ItemCode
WHERE T1.Quantity > 0
ORDER BY T0.ExpDate, T0.ItemCode

SAP HANA (column names in double quotes)

SELECT T0."ItemCode", T2."ItemName", T0."DistNumber" AS "BatchNumber", T0."ExpDate",
  T1."WhsCode", T1."Quantity", DAYS_BETWEEN(CURRENT_TIMESTAMP, T0."ExpDate") AS "DaysLeft"
FROM OBTN T0
INNER JOIN OBTQ T1 ON T1."MdAbsEntry" = T0."AbsEntry"
INNER JOIN OITM T2 ON T2."ItemCode" = T0."ItemCode"
WHERE T1."Quantity" > 0
ORDER BY T0."ExpDate", T0."ItemCode"

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

Common pitfall: OBTN alone shows batches that are already used up

Every batch ever received stays in OBTN, including batches that were sold or consumed long ago, so a report on OBTN alone lists them all. Join OBTQ and filter Quantity > 0 to see real stock, and group by warehouse, because the same batch can be split across several warehouses. Joining on ItemCode only, without SysNumber or MdAbsEntry, multiplies the rows. See Batches expiring soon query.

Ready-made queries that use OBTN

Related tables

OITM (Items (item master data)) · 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.