SAP Knowledge Base Article - Public

2931385 - Duplicate sales orders are generated in SAP S/4HANA Cloud via a single Sales Order (A2X) API request - SAP S/4HANA Cloud

Symptom

When sending an API request from external system to SAP S/4HANA Cloud system using Sales Order (A2X) via Cloud Platform Integration (CPI), duplicate sales orders are created.

Environment

SAP S/4HANA Cloud

Reproducing the Issue

  1. Send API requests from external system to SAP S/4HANA Cloud system via CPI to create sales orders. Each API request is supposed to create one sales order.
  2. For every single API service request, SAP S/4HANA Cloud 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 whitelist 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 – Headers whitelisting 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 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 , SD-SLS-API , API , SD-SLS , Sales , OPU-GW-COR , Framework , LOD-CHB-API , Content Hub – API Business Hub , Problem

Product

SAP S/4HANA Cloud all versions