SAP S/4HANA and Salesforce integration
SAP S/4HANA runs your finance and procurement. Salesforce runs your sales and customer management. Connecting the two keeps your supplier and customer master data aligned and lets you create procurements and GL journals in SAP from closed sales in Salesforce without re-entry. Customer and supplier records from SAP flow into Salesforce as Accounts and Contacts, while opportunities and orders flow back into SAP as Purchase Orders with GL cost center allocations already mapped. ml-connector bridges the very different authentication and data models on each side and moves the data on a schedule you control.
What moves between them
The main flow is SAP S/4HANA to Salesforce. Supplier records (A_Supplier, A_SupplierCompany) and Customer records (A_Customer) are read from SAP on a schedule and created as Accounts in Salesforce, with GL cost center tags stored in custom fields. Contact records follow from SAP Business Partner roles. The reverse flow is Salesforce to SAP: when an Opportunity closes or an Order is created in Salesforce, ml-connector creates a Purchase Order in SAP S/4HANA, mapping the Salesforce Account back to the corresponding SAP Supplier, and allocating GL account line items to the cost center stored during the initial sync. GL Account and Cost Center data are aligned in both directions.
How ml-connector handles it
ml-connector stores both credential sets encrypted: the SAP Communication Arrangement OAuth details (token endpoint URL, client ID, client secret, scope) and the Salesforce OAuth credentials (client ID, client secret, My Domain URL). On each poll cycle, it requests tokens from both services, caching them until expiry and refreshing before the deadline. It discovers the available OData service URLs from the tenant-specific SAP instance and maps them to the Salesforce SObject endpoints. When a supplier in SAP lacks a matching Account in Salesforce, ml-connector creates the Account and stores the SAP Business Partner ID in a custom field for reverse lookups. When an Opportunity closes in Salesforce, ml-connector queries Salesforce for the related Account's SAP ID, looks up the corresponding SAP Supplier in the cache, and creates a Purchase Order in SAP with the Opportunity amount as the PO value and the GL cost center from the Account's custom field. Salesforce session tokens expire in 2 hours, so ml-connector requests new tokens before each batch of calls rather than trying to refresh the same token. SAP tokens last 12 hours and are reused until expiry. Cost Center and GL Account dimensions are read from both systems on startup and validated before any write attempt, so Purchase Orders land on valid accounts. Every record carries a full audit trail and can be replayed if a downstream call fails.
A real-world example
A mid-market B2B software company runs SAP S/4HANA for procurement and accounting and Salesforce for sales pipeline and customer management. Before the integration, the sales team sent deal recaps to procurement via email or spreadsheet after each quarter close, and procurement manually entered the supplier and cost allocation into SAP to create a blanket purchase order. With SAP S/4HANA and Salesforce connected, suppliers and customers are synchronized automatically from SAP to Salesforce, and when an opportunity closes, the GL cost center and supplier are already known. ml-connector creates the blanket PO in SAP with no re-entry, finance reconciles in hours instead of days, and the sales team has visibility into PO status without asking procurement.
What you can do
- Sync suppliers and customers from SAP S/4HANA to Salesforce as Accounts and Contacts with GL cost center tags.
- Create Purchase Orders in SAP S/4HANA from closed Opportunities and Orders in Salesforce, with GL account and cost center mappings already in place.
- Bridge OAuth 2.0 token management on both sides, handling short-lived Salesforce tokens and longer SAP caches.
- Map GL Account and Cost Center reference data bidirectionally so procurements land on valid accounts in SAP.
- Read from SAP via OData polling and write via OData services, with full audit trail and error replay on every record.
Questions
- Which direction does data move between SAP S/4HANA and Salesforce?
- The main flow is SAP to Salesforce. Supplier, customer, and cost center records from SAP flow into Salesforce as Accounts and Contacts with GL tags. The reverse flow is Salesforce to SAP: closed Opportunities and Orders trigger Purchase Order creation in SAP with GL mappings. Cost centers and GL accounts are aligned bidirectionally to keep both systems in agreement.
- How does ml-connector handle the different token lifetimes between SAP and Salesforce?
- SAP tokens expire in 12 hours and ml-connector caches and reuses them until expiry, refreshing just before the deadline. Salesforce tokens expire in 2 hours, so ml-connector requests a fresh token before each batch of API calls rather than trying to refresh. Both credential sets are stored encrypted, and token refresh is transparent to the integration flow.
- What happens when a Salesforce Opportunity references an Account that does not exist yet in SAP?
- ml-connector validates that the Account has a SAP Supplier ID in its custom field before attempting to create a Purchase Order. If the Account was never synced from SAP, the PO creation is skipped and flagged in the audit trail. The Account can be backfilled through a manual sync or the next scheduled poll from SAP.
Related integrations
More SAP S/4HANA integrations
Other systems that connect to Salesforce
Connect SAP S/4HANA and Salesforce
Free to use. Add your credentials, ping your real systems, and see if we fit.
Get started