SAP BAPIObjectBAPI_ACC_DOCUMENT_POSTModuleFI_FICO

BAPI_ACC_DOCUMENT_POST — Generic Accounting Document Posting BAPI

BAPI_ACC_DOCUMENT_POST posts a generic FI accounting document combining GL, AR, AP and tax lines in one call, mirroring what FB01 does online. It does not commit on its own — the caller must issue BAPI_TRANSACTION_COMMIT afterward — and the RETURN table must be scanned for message type, not just checked for emptiness, or silent postings and duplicate documents follow.

This page covers BAPI_ACC_DOCUMENT_POST, the generic interface for creating accounting documents from external systems, batch loads and custom programs. It focuses on the commit step that callers routinely forget, the RETURN table logic that gets misread, and the field-status and account-determination errors that only surface at posting time rather than at the interface design stage.

Published 16 Sept 2026· 1,079 words

What it does

BAPI_ACC_DOCUMENT_POST creates an FI accounting document — the same object FB01 creates online, and the same one that lands in the document header and line item tables once posted. It is deliberately generic: a single call can carry general ledger lines, customer (AR) lines, vendor (AP) lines and tax lines together, which makes it the standard entry point for interfaces from non-SAP subledgers, billing systems, payroll feeds, bank statement postings and custom batch programs that need to create FI documents without going through the FB01 dynpro. It does not post to CO on its own; if the posting needs a cost object it relies on the account assignment fields inside the line item structures, same as manual entry would.

Important parameters

  • DOCUMENTHEADER - company code, document date, posting date, document type, reference and header text, equivalent to the FB01 header screen
  • ACCOUNTGL - table of general ledger line items with GL account, posting key, amounts and cost assignment fields
  • ACCOUNTRECEIVABLE - table of customer line items, one row per AR posting with customer number and terms
  • ACCOUNTPAYABLE - table of vendor line items, one row per AP posting with vendor number and payment terms
  • ACCOUNTTAX - table of tax line items linked back to the GL or subledger lines by item reference
  • CURRENCYAMOUNT - table carrying document currency, local currency and, where relevant, a second local currency amount per line
  • CRITERIA and EXTENSION1/EXTENSION2 - customer-defined fields passed through to enhancement points when standard fields are not enough
  • PAYMENTCARD - optional table for payment card data on the line, used in retail and card-settlement scenarios
  • RETURN - table of messages, the only reliable indicator of success or failure
  • OBJ_TYPE, OBJ_KEY, OBJ_SYS - export parameters returned on success that identify the posted document; OBJ_KEY carries the document number, company code and fiscal year concatenated

Commit behaviour

BAPI_ACC_DOCUMENT_POST does not commit the database. It runs the same validations and number range draw that FB01 would, builds the document in the work process, and hands back OBJ_KEY as if the posting succeeded — but nothing is durable until the caller explicitly calls BAPI_TRANSACTION_COMMIT (or the equivalent rollback call on failure). Forget the commit and the session ends, or the next dialog step in the same LUW triggers an implicit rollback, and the document that OBJ_KEY pointed to simply does not exist. This is the single most common defect in first-pass interface builds: the developer sees a document number returned, assumes the posting is final, and only discovers the gap when finance cannot find the document days later or when a number range shows a permanent gap.

Return handling

RETURN is a table, not a single flag, and every row has a TYPE field (S, W, E, A) that must be inspected individually — checking sy-subrc after the call or checking whether RETURN is empty tells almost nothing, because the BAPI frequently returns sy-subrc 0 alongside error rows, and it can return warning rows on an otherwise successful posting. The correct pattern loops RETURN looking for TYPE = 'E' or TYPE = 'A'; only if none are found is it safe to call the commit. A second class of bug comes from calling the commit unconditionally regardless of RETURN content, which turns a rejected posting attempt into a document anyway if some lines partially succeeded, or masks the real error behind a generic dump later in the interface chain. A third comes from parsing only the first row of RETURN for a status code and ignoring the rest, which loses the actual account-determination or tax message that explains why the whole document failed.

ECC vs S/4HANA

BAPI_ACC_DOCUMENT_POST still works on S/4HANA and remains in wide use for existing interfaces and custom batch programs; SAP has not withdrawn it. For new builds, particularly extensibility and side-by-side scenarios, SAP's published API strategy increasingly points toward OData-based journal entry creation services published through the API Business Hub rather than classic BAPIs. Existing interfaces built on this BAPI are not obliged to migrate, but new integration work is worth checking against the currently released API catalog before defaulting to it out of habit.

Common pitfalls

  • Commit omitted or conditionally skipped, so OBJ_KEY is returned but the document never exists in BKPF/BSEG
  • RETURN checked for emptiness only, letting error rows with a non-blank message text through as if the call succeeded
  • Retry logic on timeout re-sends the same payload without checking whether OBJ_KEY was already issued, creating duplicate documents
  • Required field status fields (cost center, profit center, segment) left blank in the interface mapping, rejected only at posting time with a message buried mid-table in RETURN
  • Currency amount rows in CURRENCYAMOUNT not matching the line items in ACCOUNTGL by item number, producing balancing errors that look like a program bug but are a mapping bug
  • Tax line items posted without matching the calculated tax amount to the tax code's own calculation, rejected downstream in tax reporting rather than at post time
  • Document type or number range exhausted mid-batch, stopping only some records and leaving no visible marker of which rows in the source file actually posted

Whose problem this is

The commit call, RETURN parsing and retry logic are development problems; evidence needed from functional is the field status group and account determination configuration behind whatever GL, AR or AP account the line is trying to post to. The functional side owns document type, posting key, and tax code setup; evidence needed from development is the exact RETURN row, not a summary of 'it failed'.

Related SAP objects

Reviewed pages this object connects to in the ERPClimb knowledge graph.

Source: ERPClimb — https://erpclimb.com/sap-bapis/bapi-acc-document-postERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.