ml-connector
SAP S/4HANAAdobe Commerce

SAP S/4HANA and Adobe Commerce integration

SAP S/4HANA runs finance, procurement, and the general ledger. Adobe Commerce runs the online storefront and B2B accounts. Connecting the two means web orders, the invoices captured against them, and refunds flow into SAP S/4HANA as accounting documents without re-keying, and the customer and product masters stay in agreement. ml-connector handles the very different APIs on each side and moves the data on a schedule you control. Because SAP S/4HANA owns the chart of accounts and Adobe Commerce exposes no GL resource, the general ledger stays in SAP where it belongs.

How SAP S/4HANA works

SAP S/4HANA Cloud exposes business partners, suppliers, customers, supplier invoices, purchase orders, GL accounts, journal entries, and cost centers through OData V2 and V4 services on a tenant-specific URL such as https://my123456-api.s4hana.ondemand.com. Access requires an SAP admin to create a Communication Arrangement, which issues OAuth 2.0 client credentials; there is no self-service sign-up. Tokens are short-lived and every write needs an X-CSRF-Token fetched first. SAP has no native outbound webhooks for external URLs, so records are read by polling with $filter on LastChangeDateTime, unless the customer has SAP Event Mesh on BTP.

How Adobe Commerce works

Adobe Commerce exposes orders, invoices, credit memos, customers, B2B companies, and products through its REST Commerce Web APIs, with paths under a /V1/ prefix scoped by store view on PaaS or by header on the Cloud Service. PaaS authenticates with OAuth 1.0a integration credentials or an admin bearer token, while the Cloud Service uses IMS OAuth 2.0 client credentials with tokens that expire in about 24 hours. Purchase orders, negotiable quotes, and company accounts require the B2B extension. Adobe Commerce supports synchronous outbound webhooks and async Adobe I/O Events, but exposes no GL chart-of-accounts resource.

What moves between them

The main flow runs from Adobe Commerce into SAP S/4HANA. ml-connector reads sales orders, the invoices captured against them, and credit memos from Adobe Commerce and posts them into SAP S/4HANA as accounting documents and receivables, mapped to the matching company code, GL accounts, and cost centers. Customer and B2B company records flow the same direction so the SAP business partner master reflects storefront buyers and corporate accounts. Product and SKU references are aligned so each order line resolves to a real SAP material. The general ledger stays in SAP S/4HANA, since Adobe Commerce has no GL resource, so ml-connector never writes ledger entries back to the store.

How ml-connector handles it

ml-connector stores both credential sets encrypted. On the Adobe Commerce side it signs each PaaS request with the OAuth 1.0a consumer and access tokens, or requests and refreshes an IMS OAuth 2.0 bearer token for the Cloud Service before it expires, and it scopes every call to the right store view by URL path or header. On the SAP side it requests an OAuth 2.0 client-credentials token against the tenant token URL, caches it until just before expiry, and fetches an X-CSRF-Token before any POST because SAP returns 403 without one; if a write fails on a stale token it re-fetches and retries. Because SAP cloud has no outbound webhooks, it polls Adobe Commerce orders, invoices, and credit memos on a schedule, paging through results with searchCriteria and the total_count field. Materials and business partners are mapped first, so every order line references a SAP material and a customer that already exist. Neither side ships a built-in idempotency key, so ml-connector dedupes on the Adobe Commerce increment_id and a BullMQ jobId before it posts, while SAP FI duplicate detection guards the accounting document. Where Adobe Commerce webhooks are enabled, ml-connector can take a push as a trigger while keeping its synchronous endpoint fast so checkout is not held up. Every record carries a full audit trail and can be replayed if a downstream call fails.

A real-world example

A mid-sized consumer goods manufacturer with around 600 employees runs SAP S/4HANA Cloud for finance, procurement, and inventory, and sells direct to retailers through an Adobe Commerce B2B storefront. Before the integration, a finance clerk exported each batch of web orders and keyed the sales and receivables into SAP by hand, which meant orders sat for hours, materials were sometimes mismatched, and the receivables in the ledger never tied out to storefront totals at close. With SAP S/4HANA and Adobe Commerce connected, each order and its captured invoice flow into SAP within the polling window, posted to the correct company code, customer, and material, and refunds post as credit memos. Orders book sooner, the keying errors are gone, and the sales accounts reconcile without a month-end scramble.

What you can do

  • Post Adobe Commerce sales orders and captured invoices into SAP S/4HANA as accounting documents and receivables.
  • Map Adobe Commerce SKUs to SAP S/4HANA materials so every order line lands on a real item.
  • Keep the SAP S/4HANA business partner master aligned with Adobe Commerce storefront buyers and B2B company accounts.
  • Bridge Adobe Commerce OAuth to SAP OAuth 2.0 client credentials and fetch the X-CSRF-Token before every write.
  • Poll on a schedule with increment_id and jobId dedup, retries, and a full audit trail on every record.

Questions

Which direction does data move between SAP S/4HANA and Adobe Commerce?
The main flow is Adobe Commerce into SAP S/4HANA. Sales orders, captured invoices, credit memos, and customer or B2B company records move from Adobe Commerce into SAP, while material and SKU references are aligned so order lines resolve to real items. Adobe Commerce exposes no GL account resource, so the general ledger stays in SAP S/4HANA and ml-connector never writes ledger entries back to the store.
How does ml-connector handle SAP's OAuth and X-CSRF-Token requirements?
ml-connector requests an OAuth 2.0 client-credentials token against the tenant token URL set up in the Communication Arrangement, then caches and refreshes it before its short expiry. Because SAP returns HTTP 403 on any write without a CSRF token, it fetches an X-CSRF-Token first and includes it with the session cookies on every POST. If a write fails on a stale token, it re-fetches the token and retries the request.
Does Adobe Commerce push orders, or does ml-connector poll for them?
Polling is the default because SAP S/4HANA cloud has no native outbound webhooks and is read on a schedule. ml-connector reads Adobe Commerce orders, invoices, and credit memos on that schedule, paging with searchCriteria and total_count. Where Adobe Commerce synchronous webhooks are enabled it can take a push as a trigger, while keeping the endpoint fast so storefront checkout is not stalled.

Related integrations

Connect SAP S/4HANA and Adobe Commerce

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started