ml-connector
SAP Business OneSPS Commerce

SAP Business One and SPS Commerce integration

SAP Business One runs procurement and finance for mid-sized manufacturers and distributors. SPS Commerce connects suppliers to major retailers like Walmart and Target through a managed EDI network. Connecting the two keeps your SAP purchase orders, invoices, and inventory aligned with what your retail trading partners are requesting and receiving. New orders arrive from retail channels directly into SAP without re-keying, and shipment confirmations flow back through SPS to your customers automatically.

How SAP Business One works

SAP Business One exposes purchase orders, invoices, items, chart of accounts, and profit centers through an OData v4 REST interface at a customer-provided Service Layer base URL (typically https://<customer-server>:50000/b1s/v2/ or port 50001 for HTTPS). Authentication uses a 30-minute session token obtained via POST /Login, which must be reused across calls to avoid repeated cold-start overhead. The platform also supports webhooks for Create/Update/Delete events on v10.0 FP 2602 and later if configured, but polling with UpdateDate filters is the recommended default. Each customer hosts their own Service Layer instance, so no global endpoint exists. OData associations via $expand can reduce round-trips, but many queries require separate calls. The API enforces a default page size of 20 records controlled by $top and $skip parameters.

How SPS Commerce works

SPS Commerce exposes purchase orders, invoices, advance ship notices, and functional acknowledgments through REST endpoints at https://api.spscommerce.com, with all documents wrapped in an RSX 7.7.7 JSON envelope that carries trading partner IDs and document metadata. Authentication is OAuth 2.0 client credentials, with the token endpoint at https://api.spscommerce.net/authorization/v1/token (note the different domain for token requests). The primary sync pattern is polling /fulfillment/v1/purchaseorders on a configurable interval (5-15 minutes), with pagination via cursor-based opaque Base64 strings. SPS is a pass-through network intermediary and does not store business state; all documents are wrapped in the RSX envelope. Rate limits are not publicly documented and vary by endpoint. Push (immediate outbound send) is recommended for outbound invoices and shipment advice from the ERP.

What moves between them

The main flow runs from SPS Commerce into SAP Business One. Purchase orders from retail trading partners arrive at SPS, which publishes them via the polling endpoint. ml-connector reads these orders on a scheduled interval, unwraps the RSX envelope, maps line items and quantities to SAP item numbers and profit centers, and posts the purchase orders and line details into SAP's PurchaseOrders and PurchaseOrderLines tables via OData. Shipment notifications (ASNs) flow the same direction. When a shipment occurs in SAP, the outbound flow sends the invoice and shipment advice back through SPS to the trading partner. The inbound cadence (5-15 minutes) is configurable; outbound is immediate on SAP event.

How ml-connector handles it

ml-connector stores the SPS OAuth client ID and secret encrypted, and the SAP Business One Service Layer base URL and login credentials encrypted as well. On each poll cycle, it requests a fresh SPS bearer token (cached for the token lifetime), calls the cursor-based /fulfillment/v1/purchaseorders endpoint, and iterates through the paginated result. Each document is unwrapped from the RSX 7.7.7 envelope to extract the actual order and line item data. ml-connector then logs into SAP Business One (reusing the session token across multiple API calls to avoid cold-start overhead), maps the document to SAP PurchaseOrders and line items, checks if the document number already exists in SAP (deduplication via DocNum), and inserts or updates accordingly. If SPS returns a 429 rate-limit response, ml-connector backs off with exponential jitter and retries. For outbound, when an invoice event occurs in SAP (via polling or webhook if enabled), ml-connector reads the full invoice record from SAP, wraps it in the RSX envelope with the correct trading partner ID (provisioned during SPS onboarding), and POSTs it to SPS. The SAP session token expires after 30 minutes of inactivity, so ml-connector detects -5002 errors and logs in again. Every record is audited with source document ID, timestamp, and result state.

A real-world example

A mid-sized packaged-goods distributor supplies Walmart, Target, and Amazon through SPS Commerce. Before the integration, the operations team received purchase orders from SPS as daily SFTP file drops in X12 format, parsed them manually or with a custom script, and hand-entered the key fields (order number, SKU, quantity, delivery date) into SAP Business One. This was error-prone and delayed order fulfillment by a day. With SAP Business One and SPS Commerce connected via ml-connector, each Walmart order arrives at SPS and is automatically posted into SAP within 15 minutes as a standard purchase order. The warehouse sees the order in SAP immediately, and when goods are packed and shipped, the shipment confirmation flows back through SPS to the retailer without a separate export step. Month-end invoicing is now automated, and the source of truth for open orders is a single SAP report, not scattered between SPS and a homemade tracker.

What you can do

  • Pull purchase orders from SPS Commerce's EDI network and post them into SAP Business One as standard purchase orders with line items and profit centers.
  • Unwrap SPS's RSX JSON envelope and map trading partner identifiers to the correct SAP cost center or business unit.
  • Handle OAuth2 token refresh on SPS and SAP Business One session token renewal separately, keeping both connections alive across polling cycles.
  • Deduplicate incoming orders by document number and detect updates to existing orders so the same order is never double-posted.
  • Push invoices and shipment notifications from SAP back to SPS Commerce immediately when created, wrapping them in the RSX envelope for retail trading partners.

Questions

How does ml-connector handle the different authentication schemes on SAP Business One and SPS Commerce?
SAP Business One uses session-based auth with a 30-minute timeout, so ml-connector logs in once, reuses the session token across multiple OData calls to avoid cold-start overhead, and detects timeout errors (-5002) to trigger a fresh login. SPS Commerce uses OAuth2 client credentials, so ml-connector requests a bearer token from the SPS token endpoint (https://api.spscommerce.net/authorization/v1/token), caches it for its lifetime, and refreshes when needed. Both credential sets are stored encrypted at rest.
Why is SPS Commerce's RSX envelope important to understand when syncing with SAP Business One?
Every document at SPS (purchase order, invoice, shipment) is wrapped in an RSX 7.7.7 JSON envelope that carries the trading partner ID, message type, and metadata. ml-connector must unwrap this envelope to extract the raw order or invoice data and map it to SAP fields. On the outbound side (SAP to SPS), ml-connector must wrap the SAP invoice in the same RSX envelope with the correct trading partner ID before posting it back to SPS, otherwise the retail partner will not recognize it.
What happens if a purchase order arrives at SPS Commerce multiple times before ml-connector processes it?
ml-connector deduplicates by checking the purchase order number (DocNum in SAP) before posting. If the order already exists in SAP, ml-connector skips the insert or updates fields like quantity or delivery date depending on your configuration. This prevents duplicate GL postings and inventory reservations. ml-connector logs every check and decision in the audit trail.

Related integrations

Connect SAP Business One and SPS Commerce

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

Get started