> ## 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 Create Supplier Invoice

> Parks or posts a supplier invoice in SAP, with purchase-order lines, G/L lines or both.

Creates a supplier invoice in SAP (`A_SupplierInvoice` in `API_SUPPLIERINVOICE_PROCESS_SRV`). Display name **"SAP Create Supplier Invoice"**. Off by default.

`supplier_invoice_status` decides how it lands:

* `A` parks it. This is the default.
* `B` parks it as complete.
* `5` asks SAP to post it to the ledger.

## Authentication and enablement

Requires a workspace SAP integration. `base_url` and `authorization` are injected. Enable the tool and bind the integration.

## Check for a duplicate first

The tool does not look for an existing invoice before it creates one. Search with `sap_read_supplier_invoice` on `invoicing_party` and `reference_starts_with` first; that page explains why a prefix match catches re-keyed references. Both tools cut the supplier's reference to 16 characters the same way, so the keys match.

## Inputs

| Field | Required | Notes |
| - | - | - |
| `invoicing_party` | yes | Supplier number. |
| `company_code` | yes | |
| `document_date` | yes | Invoice date, `YYYY-MM-DD`. |
| `posting_date` | yes | Decides the accounting period. Never defaulted. |
| `invoice_gross_amount` | yes | Decimal string. Must equal the sum of every line amount, PO and G/L together. |
| `document_currency` | yes | e.g. `USD`. A line or tax item without its own currency takes it. |
| `supplier_invoice_id_by_invoicing_party` | yes | The supplier's reference as printed. Longer than 16 characters is cut to the first 16 and reported in `truncated`; do not pre-trim it. |
| `supplier_invoice_status` | — | `A`, `B` or `5`. Anything else is refused before SAP is called. |
| `line_items` | unless `gl_account_items` | PO reference lines, below. |
| `gl_account_items` | unless `line_items` | G/L lines, below. |
| `tax_items` | — | `tax_code` and `tax_amount` (required), `tax_base_amount`, `tax_jurisdiction`, `document_currency`. Sent as given: nothing is computed from a rate. |
| `tax_is_calculated_automatically` | — | `true` asks SAP to calculate the tax from the lines' tax codes. |
| `payment_terms` | — | Omit it and SAP applies the supplier's own terms. |
| `payment_blocking_reason` | — | e.g. `A`. |
| `assignment_reference` | — | |
| `document_header_text` | — | Cut to 25 characters and reported in `truncated`. |
| `fiscal_year` | — | Not sent to SAP. It labels the result only when SAP's response carries no fiscal year. |
| `baseline_date` | — | `YYYY-MM-DD`. Drives the due date, so it changes when the invoice is paid, not only how it reads. |
| `accounting_document_type` | — | e.g. `RE`. |
| `unplanned_delivery_cost` | — | Freight or handling SAP spreads itself. Needs `unplanned_delivery_cost_tax_code` alongside it. |
| `unplanned_delivery_cost_tax_code` | — | |
| `unplanned_delivery_cost_tax_jurisdiction` | — | |
| `unplanned_delivery_cost_tax_country` | — | |
| `business_place` | — | |
| `is_credit_memo` | — | `true` books a credit memo. Sent to SAP as its single character, not a JSON boolean. Pair it with `invoice_reference`. |
| `invoice_reference` | — | The invoice being credited. |
| `invoice_reference_fiscal_year` | — | Its fiscal year. |
| `withholding_tax` | — | Withholding tax lines, below. |

**PO reference lines** (`line_items`): `purchase_order`, `purchase_order_item` and `supplier_invoice_item_amount` are required. Optional: `plant`, `tax_code`, `tax_jurisdiction`, `document_currency`, the quantity fields (`quantity_in_purchase_order_unit`, `purchase_order_quantity_unit`, `purchase_order_qty_unit_iso_code`, `qty_in_purchase_order_price_unit`, `purchase_order_price_unit`), and the goods receipt the line settles (`reference_document`, `reference_document_fiscal_year`, `reference_document_item`).

A PO line can also carry `account_assignments`, for the case where the invoice splits a line differently from the purchase order. Each entry takes any of `cost_center`, `gl_account`, `profit_center`, `wbs_element`, `internal_order`, `business_area`, `functional_area`, `controlling_area`, `amount`, `quantity`, `quantity_unit`, `tax_code`, `tax_jurisdiction`, `text` and `document_currency`. Send them only when the split differs from the PO item's own.

**Withholding tax** (`withholding_tax`), on the header: `withholding_tax_type`, `withholding_tax_code`, `withholding_tax_base_amount` and `withholding_tax_amount` are all required — SAP refuses a partial line rather than defaulting it. `document_currency` is optional.

**G/L lines** (`gl_account_items`), for charges with no PO line such as freight or handling: `gl_account` (10 digits, zero-padded, e.g. `0041000000`) and `supplier_invoice_item_amount` are required. Optional: `debit_credit_code` (`S` debit, `H` credit), `tax_code`, `tax_jurisdiction`, `cost_center`, `internal_order`, `profit_center`, `business_area`, `wbs_element`, `functional_area`, `assignment_reference`, `supplier_invoice_item_text`, `quantity`, `quantity_unit`, `document_currency`. G/L lines take the header `company_code`.

Lines are numbered 1, 2, 3 in the order given, PO lines and G/L lines separately; a line number in the input is ignored. Either list can also be passed as a `${VAR_N}` reference or a path into one.

Nothing else is defaulted or derived. `plant`, `tax_code`, `payment_terms`, `quantity` and `debit_credit_code` are sent only when supplied; when they are absent SAP applies the purchase order's or the supplier's own values.

## Outputs

* `supplier_invoice_number`, `fiscal_year`, `status` (SAP's), `post_requested` and `posted`.
* `company_code`, `invoicing_party`, `invoice_gross_amount`, `document_currency`, `supplier_invoice_id_by_invoicing_party`, `document_date` and `posting_date` as SAP stored them. Dates are written out, e.g. "October 8, 2026".
* `line_item_count`: PO reference lines only. G/L lines are not counted.
* `tax_amount` and `tax_code`: what was sent in `tax_items`, not a figure SAP calculated.
* `truncated`: each field that was cut.
* `sap_messages`: what SAP said about the document, such as a payment block, a tolerance warning or a duplicate reference. None of these appear in the document itself, so read them.
* `full_details`: the document as SAP returned it.
* `sap_url` when the connection has a Fiori launchpad URL.

<Warning>
  `5` asks SAP to post; it does not guarantee a post. A payment block, a tolerance or a closed period can leave the invoice parked while the call still succeeds. Check `posted`, not `post_requested`.
</Warning>

## Limits and side effects

* **Writes to SAP.** A posted invoice cannot be undone with this tool; in SAP a posted document is reversed, not deleted.
* **Sent once.** The create is never retried: a resend after a late answer once created a duplicate invoice. If the call times out (60 seconds) or SAP's response cannot be read, the invoice may exist anyway. Search with `sap_read_supplier_invoice` before calling again.
* **No local balance check.** An invoice whose lines do not add up to `invoice_gross_amount` is refused by SAP with M8/186.
* **Tax is never computed here.** Without `tax_items` or `tax_is_calculated_automatically`, a taxed invoice is parked without its tax, or refused on posting with M8/186.
* Withholding tax is not supported. Attach the invoice image with `sap_upload_attachment` after creating it.

## Expected errors

| Error | Meaning |
| - | - |
| `validation error: …` | A required header field is empty, there is no line of either kind, or the status is not `A`, `B` or `5`. Nothing was sent. |
| `invalid document_date` / `invalid posting_date` | The date is not `YYYY-MM-DD`. Nothing was sent. |
| `failed to fetch CSRF token` | SAP refused the token request. Nothing was written. |
| M8/186 "Balance is not equal to zero" | The header amount differs from the sum of the lines, or tax is missing on a post. |
| M8/757 "Enter a tax jurisdiction code" | Posting in a country that needs `tax_jurisdiction` on each line, such as Brazil. |
| A timeout, or `failed to decode response` | The outcome is unknown. Check for the invoice before calling again. |

SAP's own messages are appended to the error text, so a refusal names SAP's reason.


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