> ## Documentation Index
> Fetch the complete documentation index at: https://agents.nanonets.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SAP Post Journal Entry

> Posts one or more balanced G/L journal entries to SAP via the SOAP Journal Entry Create service, with simulate/commit, planned reversal and batch support.

Posts G/L journal entries to SAP through the SOAP service `JournalEntryCreateRequestConfirmation_In` (bulk). Display name **"SAP Post Journal Entry"**. Off by default. This is the only SAP tool that uses SOAP rather than OData, so it needs a **direct S/4HANA connection** — a SAP Integration Suite (iflow) connection does not expose the SOAP endpoint and is refused with a clear message.

## Authentication and enablement

Requires a workspace SAP integration. `base_url`, `authorization` and `sap_client` are injected. Two configured-tool bindings (editable in the tool's configuration, not LLM arguments) control the rest:

* **`journal_entry_create_soap_path`** — the endpoint path (after the host) of the Journal Entry Create binding configured in SOAMANAGER. Leave blank to use the standard binding for the connection's SAP client — the client is a segment of the SRT URL, so the default is built from `sap_client` rather than hard-coded (a fixed client would post to the wrong client on a non-100 system). Override it only if your system publishes the service under a non-standard binding.
* **`created_by_user`** — the SAP user recorded as the document creator (structurally required by the service); no default.

## Inputs

* `test_run` (boolean, **required**) — `true` simulates/validates only (no document committed); `false` posts a real document and returns its number. There is no default: the model must state its intent on every call.
* `entries` (required) — one or more journal entries. Each entry: `company_code`, `posting_date` (required), optional `document_date`, `document_type` (default `SA`), `business_transaction_type` (default `RFBU`), `document_header_text`, and `reversal_reason` + `reversal_date` for a planned reversal. `document_reference_id` (XBLNR, ≤16 chars) is **required for a real post** (`test_run=false`) — it is the idempotency key a duplicate check and the post-timeout recovery rely on; a simulate does not need one. This tool does not perform the duplicate check itself.
* Each entry's `items` (≥2) carry `gl_account`, a **positive** `amount`, `currency`, `debit_credit_code` (`S` = debit, `H` = credit), optional `document_item_text`, `assignment_reference`, and account assignment (`cost_center`, `profit_center`, `segment`, `order_id`, `wbs_element`, `functional_area`).

**Field handling before sending:** currency is upper-cased; numeric G/L / cost-centre / profit-centre codes are zero-padded to SAP's 10-char width; and the descriptive fields are truncated to SAP's field widths — document header text 25, item text 50, **assignment reference 18** — with a warning in the result when any truncation happened (the assignment reference is the clearing key, so shorten it yourself if the full value matters). An `amount` with more decimal places than its currency allows is rejected rather than silently rounded.

The tool applies the SAP sign convention (debit positive, credit negative) from `debit_credit_code`, and rejects an entry that does not balance before sending. The balance check is per currency and at the precision actually posted (each amount is formatted to the currency's decimals — 2 for EUR/USD, 0 for JPY, 3 for KWD), so an entry that only balances as raw floats, or only across currencies, is caught. Numeric G/L / cost-centre / profit-centre codes are zero-padded to SAP's field width before sending.

## Batch

Several `entries` post in one call. Each entry commits independently, so a batch can partially succeed — give each entry a unique `document_reference_id` and run a duplicate check first so a re-run is safe. When a batch partially fails, the error text lists each entry's committed document number (not just the first error), so a retry re-posts only the entries that did not commit. If SAP never confirms the outcome (timeout, gateway 502/504), the tool reports the document **may already exist** and tells the agent to check with the duplicate read rather than resend — it never replays a write.

## Output

`structuredContent` carries `status` (`posted` / `simulated` / `error`), `test_run`, and `confirmations`. Each confirmation has `accounting_document`, `company_code`, `fiscal_year`, severity and log messages, plus a `document` object — the posted entry's header (document type, business transaction type, dates, header text, created-by, planned reversal) and line items (G/L, debit/credit, signed amount, account assignment, text) — so the review card renders the complete document for both a simulate and a commit. A real post also includes a `sap_url` deep link. A SOAP fault or a severity-3 log sets `IsError: true`.

## Validation Status

Provisional. The SOAP message format and the standard EUR / client-100 path are verified live against s4h-2022 through the worker — a real commit returned a new accounting document and the duplicate read then found it. Not yet exercised against SAP: the client-derived path on a non-100 system, non-EUR currency precision (JPY 0-decimal, KWD 3-decimal), code padding, and the Integration Suite refusal. Not yet validated against a customer production connection.

## Errors

`IsError: true` is set for: a missing integration; a SAP Integration Suite connection (SOAP is not exposed there); no SOAP path and no `sap_client` to derive one from; a missing `created_by_user`; a missing `document_reference_id` on a real post; an invalid or incomplete date (a planned reversal needs both reason and date); an amount with too many decimals for its currency; an unbalanced entry; a SOAP fault; a severity-3 SAP log (e.g. closed posting period); a commit confirmation with no document number; a non-2xx response without a fault; or a response that is neither a fault nor a confirmation (never counted as a successful post). A batch whose confirmation count does not match the entries sent is an error with the outcome marked unknown. On a commit, a timeout, gateway 502/504, or an unreadable 2xx is reported as **outcome unknown** (the document may already exist — check with the duplicate read, do not resend).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.