OPCH table in SAP Business One (A/P Invoice (header))
OPCH is the SAP Business One table that stores the header of every A/P (vendor) invoice: vendor, dates, totals, tax and amount paid. Its lines are in PCH1, joined on DocEntry, and its object type is 18.
OPCH key fields
| Field | What it holds |
|---|---|
DocEntry | Internal key. Joins to PCH1.DocEntry. |
DocNum | Internal invoice number in SAP B1. |
NumAtCard | Vendor reference: the vendor's own invoice number. |
DocDate | Posting date. |
DocDueDate | Due date for payment. |
CardCode | Vendor. Joins to OCRD.CardCode (CardType = S). |
CardName | Vendor name. |
DocTotal | Total including tax. |
VatSum | Tax amount. |
PaidToDate | Amount already paid. DocTotal - PaidToDate is the open balance. |
DocStatus | O = open, C = closed. |
CANCELED | N = normal, Y = cancelled, C = cancellation document. |
How OPCH relates to other tables
OPCH is the header and PCH1 the lines, joined on DocEntry. A/P invoices are usually copied from a goods receipt PO (OPDN) or a purchase order (OPOR); that link is on the lines in PCH1.BaseType, BaseEntry and BaseLine. A/P credit memos are a separate table, ORPC.
Common joins
OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry (lines)OPCH T0 INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode (vendor)RPC1 T3 ON T3.BaseType = 18 AND T3.BaseEntry = T0.DocEntry (credit memos against the invoice)
When you use the OPCH table
Use OPCH for payment planning, vendor aging, purchase analysis and last purchase price checks. NumAtCard is what you search when a vendor calls about their invoice number.
Example query: open vendor invoices by due date
SQL Server
SELECT T0.DocNum, T0.NumAtCard, T0.CardCode, T0.CardName, T0.DocDueDate, T0.DocTotal, T0.PaidToDate, T0.DocTotal - T0.PaidToDate AS OpenAmount FROM OPCH T0 WHERE T0.DocStatus = 'O' AND T0.CANCELED = 'N' ORDER BY T0.DocDueDate
SAP HANA (column names in double quotes)
SELECT T0."DocNum", T0."NumAtCard", T0."CardCode", T0."CardName", T0."DocDueDate", T0."DocTotal", T0."PaidToDate", T0."DocTotal" - T0."PaidToDate" AS "OpenAmount" FROM OPCH T0 WHERE T0."DocStatus" = 'O' AND T0."CANCELED" = 'N' ORDER BY T0."DocDueDate"
Paste either version in Tools → Queries → Query Generator. Need the other dialect for your own query? Use the SQL to HANA converter.
Common pitfall: Credit memos are not in OPCH
A vendor credit memo is stored in ORPC, not as a negative OPCH row. For net purchases, subtract ORPC; for open balances, use DocTotal - PaidToDate on open documents of both tables. See Vendor aging (AP aging) query.
Ready-made queries that use OPCH
- Last purchase price per item: The most recent A/P invoice price, vendor and date for every item.
- Vendor aging report (AP aging): Open A/P invoice balance per vendor in due-date buckets.
Related tables
ORPC (A/P Credit Memo (header)) · OCRD (Business Partners) · OJDT (Journal Entry (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.
