Symptom
When sending an API request from external system to SAP S/4HANA Cloud Public Edition system using Sales Order (A2X) via Cloud Platform Integration (CPI), duplicate sales orders are created.
Environment
SAP S/4HANA Cloud Public Edition
Reproducing the Issue
- Send API requests from external system to SAP S/4HANA Cloud Public Edition system via CPI to create sales orders. Each API request is supposed to create one sales order.
- For every single API service request, SAP S/4HANA Cloud Public Edition creates duplicate sales orders with the same content.
Cause
The likely cause of duplicates is due to the customer invoking the integration multiple times with the same data. Due to network issues, not until the S4HC system replies with a response code does the customer trigger another API call to CPI.
In case you are using CPI to invoke the API endpoint, you can use CPI Message IDs to troubleshoot the duplicate calls. All CPI messages include the header “SAP_MessageProcessingLogID” which gets forwarded to the backend side of S4HC system. You can use the value of this header to search for the message in the CPI monitoring. For some adapters such as OData, you may need to explicitly allowlist this header to include it in the HTTP requests to S4HC system.
For more details, you may refer to the following blog.
SAP Cloud Platform Integration – Allowed Headers in OData V2 Outbound Connector
Resolution
You can choose one of the following options to avoid such issue based on your own business needs.
Option 1:
When sending Sales Order (A2X) API requests, use field SalesOrder (key) in the payload as the unique identifier to distinguish different API requests. Then SAP S/4HANA Cloud Public Edition will create sales orders saparately based on each API request and duplicate orders can be avoided.
Option 2:
Alternatively, set up a SOAP API communication arrangement for this scenario. That will guarantee that each API service request will only be triggered once and the CPI will not wait for the response. For this scenario, Sales Order (A2A) can be used and there is an external document ID field which will function as a unique key.
Option 3:
Extend the timeout period from the CPI point of view.
See Also
Keywords
CPI, Sales Order, API, OData API, SOAP API, Sales Order (A2X), Sales Order (A2A), API_SALES_ORDER_SRV, SALESORDERBULKREQUEST_IN, SAP_MessageProcessingLogID , KBA , allowlist , SD-SLS-API , API , SD-SLS , Sales , OPU-GW-COR , Framework , SD-SLS-API-2CL , API (Public Cloud) , LOD-CHB-API , Content Hub – API Business Hub , Problem