ADOC table in SAP Business One (Document History (invoice history))
ADOC is the SAP Business One history table for documents (the SDK names it "Invoice - History"): it keeps earlier versions of document headers, one row per saved version, numbered by LogInstanc. It has the same header columns as the document tables, so you can see who changed a document, when, and what the total was before.
ADOC key fields
| Field | What it holds |
|---|---|
DocEntry | Internal key of the document. |
DocNum | Document number. |
ObjType | Object type of the document (ADP1), for example 13 for A/R invoices. |
LogInstanc | Log instance: the version number of the history row. |
DocDate | Posting date. |
CardCode / CardName | Business partner. CardCode joins to OCRD. |
DocCur / DocTotal | Document currency and total in that version. |
DocStatus | O = open, C = closed. |
CANCELED | Y = canceled, N = not canceled, C = cancellation. |
UserSign / UserSign2 | Creating user and updating user. Join to OUSR.USERID. |
CreateDate / UpdateDate | Creation and update dates. |
UpdateTS | Update time. |
How ADOC relates to other tables
ADOC rows are identified by ObjType, DocEntry and LogInstanc together, because one table holds versions of different document types. The current version stays in the document table (for example OINV), so compare the ADOC versions with the live row to see what changed. UserSign2 tells who saved each version.
Common joins
ADOC T0 INNER JOIN OUSR T1 ON T1.USERID = T0.UserSign2 (user who saved the version)ADOC T0 INNER JOIN OINV T2 ON T2.DocEntry = T0.DocEntry AND T0.ObjType = '13' (current invoice)
When you use the ADOC table
Use ADOC for audit questions such as who changed this invoice and when, to see the total of a document before an edit, and to count changes per user.
Example query: change history of one a/r invoice
SQL Server
SELECT T0.LogInstanc, T0.UpdateDate, T0.UpdateTS, T1.USER_CODE, T1.U_NAME, T0.CardCode, T0.DocTotal, T0.DocStatus FROM ADOC T0 LEFT JOIN OUSR T1 ON T1.USERID = T0.UserSign2 WHERE T0.ObjType = '13' AND T0.DocNum = 1001 ORDER BY T0.LogInstanc
SAP HANA (column names in double quotes)
SELECT T0."LogInstanc", T0."UpdateDate", T0."UpdateTS", T1."USER_CODE", T1."U_NAME", T0."CardCode", T0."DocTotal", T0."DocStatus" FROM ADOC T0 LEFT JOIN OUSR T1 ON T1."USERID" = T0."UserSign2" WHERE T0."ObjType" = '13' AND T0."DocNum" = 1001 ORDER BY T0."LogInstanc"
Paste either version in Tools → Queries → Query Generator. Need the other dialect for your own query? Use the SQL to HANA converter.
Common pitfall: Filtering ADOC by DocNum or DocEntry alone
ADOC holds history of several document types, so DocEntry 1001 can be an invoice, a credit memo or another document. Always filter ObjType as well. The current version is not in ADOC; read it from the document table and add it to the history list. See Documents created by user query.
Ready-made queries that use ADOC
- Invoices created per user today: How many A/R invoices each SAP B1 user created today, with the total value.
Questions about the ADOC table
Where is the change history of an invoice?
In ADOC, one row per saved version (LogInstanc), filtered by ObjType 13 and DocEntry.
How do I see who changed a document?
Join ADOC.UserSign2 to OUSR.USERID and order by LogInstanc.
Is the current version of the document in ADOC?
The live version stays in the document table, for example OINV; ADOC keeps earlier versions.
Related tables
OUSR (Users) · OINV (A/R Invoice (header)) · 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.
