ml-connector
SAP S/4HANASPS Commerce

SAP S/4HANA and SPS Commerce integration

SAP S/4HANA runs procurement, finance, and supply chain. SPS Commerce routes your transactions to retail trading partners like Walmart and Target via EDI. Connecting the two lets you publish purchase orders, invoices, and shipment data from S/4HANA directly to SPS Commerce without manual re-entry or SFTP file drops. Every document is wrapped in the RSX JSON format SPS requires and tracked end-to-end, so you know when each order reached your trading partners.

How SAP S/4HANA works

SAP S/4HANA exposes purchase orders, supplier invoices, advance ship notices, business partners, GL accounts, and cost centers through OData V2 and OData V4 REST APIs over HTTPS. Access is controlled via OAuth 2.0 client credentials issued by a Communication Arrangement that your SAP admin creates. Tokens are short-lived and cached; the base URL and token endpoint are tenant-specific and must be copied from your Communication Arrangement. SAP S/4HANA has no native webhooks, so transactions are read by polling with timestamps or delta tokens. The GL Account and Cost Center APIs are read-only.

How SPS Commerce works

SPS Commerce is a REST-native EDI network platform that wraps all documents in RSX JSON envelope format version 7.7.7. It authenticates via OAuth 2.0 client credentials with a separate token endpoint at api.spscommerce.net. All documents are pulled from SPS via cursor-based pagination on /fulfillment/v1/purchaseorders and similar endpoints; outbound documents like invoices and ASNs are pushed to SPS immediately. SPS is a pass-through intermediary, not a source-of-truth system, and requires trading partner IDs to be provisioned during onboarding. Rate limits are not public; exponential backoff on 429 is mandatory.

What moves between them

The main flow runs from SAP S/4HANA into SPS Commerce. Purchase orders and invoices stored in SAP S/4HANA are polled via OData at configurable intervals, transformed into SPS Commerce EDI document types (850 for POs, 810 for invoices, 856 for ASNs), wrapped in RSX JSON envelopes, and posted to SPS REST endpoints. Reference data such as business partners and supply schedules are synchronized first to ensure every PO maps to a valid trading partner already provisioned in SPS. Inbound documents from SPS (PO acknowledgments, receipts) are polled separately and can be written back to SAP as purchase order line confirmations if needed.

How ml-connector handles it

ml-connector maintains two encrypted credential sets: SAP S/4HANA OAuth client credentials and SPS Commerce OAuth credentials. On the SAP side it caches tokens and refreshes them when they expire or a call returns 401. On the SPS side it posts to the token endpoint at api.spscommerce.net (distinct from the api.spscommerce.com base URL) and stores the JWT bearer token. Every purchase order and invoice polled from SAP S/4HANA is mapped to its SPS document type and wrapped in the RSX 7.7.7 JSON envelope with the trading partner ID that SPS requires. When pushing documents to SPS, ml-connector deduplicates by document number and invoice number to prevent resubmission. SPS rate limits are unknown, so ml-connector implements exponential backoff with jitter on any 429 response. Inbound documents from SPS are read via cursor-based pagination, with the cursor decoded and cached for the next interval poll. Every document transformed carries a full audit trail and can be replayed if a downstream call fails.

A real-world example

A mid-sized consumer goods manufacturer sources from dozens of retailers including Walmart, Target, and regional chains. Before the integration, the supply chain team exported purchase orders and shipping notices from SAP S/4HANA as CSV, manually transformed them into X12 and EDIFACT files, and uploaded them to SPS Commerce via SFTP. When a retailer rejected an order format, it took days to identify the issue because the transformation was manual and opaque. With SAP S/4HANA and SPS Commerce connected, every purchase order flows directly from SAP into SPS as an RSX JSON 850 document, validated against the trading partner's requirements before posting. When SPS returns a PO acknowledgment, it is pulled back and recorded as a line confirmation in SAP automatically. The manual file drop step is gone, and the supply team sees failures in real time.

What you can do

  • Export purchase orders from SAP S/4HANA and post them to SPS Commerce as EDI 850 documents in RSX JSON format.
  • Send invoices and advance ship notices (ASNs) from SAP to SPS on a scheduled or event-driven basis, wrapped in the RSX envelope.
  • Validate trading partner IDs and business partner mappings before posting so documents reach the correct retail partner.
  • Handle OAuth 2.0 token refresh for both SAP S/4HANA and SPS Commerce, with automatic retries and exponential backoff on rate limits.
  • Receive PO acknowledgments and receipts from SPS, poll via cursor-based pagination, and record confirmations back to SAP purchase order lines.

Questions

What documents move between SAP S/4HANA and SPS Commerce, and in what direction?
The primary flow is SAP S/4HANA to SPS Commerce. Purchase orders, invoices, and advance ship notices are exported from SAP and posted to SPS as EDI 850, 810, and 856 documents respectively, wrapped in RSX JSON envelopes. Inbound documents like PO acknowledgments (855) and receipt confirmations (944) are polled from SPS and can be recorded back to SAP purchase order lines.
Does ml-connector handle the RSX JSON envelope format that SPS requires?
Yes. ml-connector wraps every outbound document in the RSX 7.7.7 JSON envelope with the trading partner ID that SPS requires. When documents are read from SPS, the RSX envelope is unwrapped and the inner EDI data is available for mapping back to SAP fields.
How does ml-connector handle SAP S/4HANA's tenant-specific URLs and SPS's dual token endpoints?
ml-connector stores the full SAP S/4HANA tenant URL and token endpoint URL from your Communication Arrangement and caches OAuth tokens per endpoint. For SPS, it routes token requests to api.spscommerce.net (the token endpoint) while routing all data calls to api.spscommerce.com (the base API URL), since the two domains are intentionally separate.

Related integrations

Connect SAP S/4HANA and SPS Commerce

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

Get started