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
| Field | What it holds |
|---|---|
AbsEntry | Internal key of the batch. OBTQ.MdAbsEntry points to it. |
ItemCode | Item the batch belongs to. Joins to OITM.ItemCode. |
SysNumber | Internal batch number per item. Together with ItemCode it identifies the batch. |
DistNumber | The batch number users see and print. |
MnfSerial | Batch attribute 1 (often the manufacturer batch). |
LotNumber | Batch attribute 2. |
ExpDate | Expiry date. |
MnfDate | Manufacturing date. |
InDate | Date the batch was received. |
Status | 0 = released, 1 = not accessible, 2 = locked. |
OBTQ.WhsCode | Warehouse that holds the quantity. |
OBTQ.Quantity | Quantity of the batch in that warehouse. |
OBTQ.CommitQty | Quantity 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
- Batches expiring in the next 60 days: Batch numbers with stock that expire within 60 days, per warehouse.
- Stock by warehouse: On hand, committed, ordered and available quantity per item and warehouse.
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.
