
This blog will provide an introduction and demo on using the OData v4 APIs in SAP S/4HANA Cloud. Specifically this blog will demo the the asynchronous processing capability of the Sales Order API. This API enables sales order management in S/4 across different systems from both an integration and extensibility perspective. Furthermore, its asynchronous processing capabilities bring notable advantages for scaling large operations over synchronous calls.
In a synchronous API call, the calling system immediately knows the status of the request, for example order number 123 has been created or order was not created because of a certain error. However, imagine a scenario where you have a high volume of sales transactions in your e-commerce platform with integration back to SAP S/4HANA for real-time sales order creation. In this case, handling thousands of sales orders simultaneously can overload the system and lead to performance bottlenecks. The SOAP based asynchronous API for sales orders has traditionally filled this requirement for customers, however OData v4 is now an option as well which may be better suited for many development and integration scenarios.
In addition to high volume API calls directly via A2A, this API is well suited for event driven architectures as well as when there is complex sales order process with additional validations where an immediate response to the calling system is not necessary.
Note: there is also a new capability in the synchronous API to minimize the amount of data returned by the API which could also be used in high volume scenarios. This can be found in the API documentation but is achieved by setting a Header value "prefer" = "return=minimal"
The Sales Order API details can be found in the SAP Business Accelerator Hub. The Documents tab on each API provides a link to the Business Documentation that contains detailed information in addition to sample payloads, which is extremely helpful for integration and extensibility development.
You need to fetch the x-csrf-token first via a GET request using the API and then use this Header value in order POST an order. You will also need to set an additional header to indicate that the order should be processed asynchronously: prefer=respond-async as outlined in the business documentation.
Create Sales Order Headers
You can modify the sample payload from the business documentation to create the Sales Order per your requirements:
Sales Order Payload
When submitted, the SAP S/4HANA system simply returns a 202 Accepted with no payload. At this point your processing would be completed and control would be returned to the calling application (UI5 app, iFlow on Integration Suite, etc).
202 Response with no body
Location URL as part of Header
If you were developing an integration, you would need to save the location for processing at a later point in time. The Location Header parameter in the response contains the URL for the status and can be called exactly one time shown in the following figures:
Location Call for Order
Subsequent Location Call not Found
Now let's take a look at the behavior with a payload containing an error, in this case a customer number that doesn't exist in SAP. The first thing to note is that you will get a 202 successful message on the first call since SAP S/4HANA Cloud simply acknowledges that it received the request successfully.
Sales Order with non-existent Customer Number
The call back for the location shows the error message.
Error Message Using Location URL in API
In addition, the monitoring applications can be used in SAP S/4HANA Cloud to see if there were any errors. This is very useful when you have thousands of messages coming into SAP and you want a business analyst to quickly check for failures. These users don't need to be technical nor use technical tools and instead they can use an intuitive dashboard within the SAP S/4HANA Cloud application.
The screenshot below in the Message Monitoring Overview app contains the component view for monitoring based on assigned components. You can use the Assign Recipients to Users app and assign the namespace /SDSLS and recipient name SDSLS_SO_ODATA_IN_RECIPIENT for this example.
A user could have many components and view all APIs and their statuses from a dashboard view in the Message Monitoring Overview app.
Message Monitoring Overview
A summary of all error messages generated on the API can be found in the Message Monitoring App.
Message Monitoring of Errors
The exact error message can be found in the detailed log messages.
Detailed Error Message
This blog introduced the asynchronous processing capabilities in OData v4 APIs in SAP S/4HANA Cloud including how and why it could be used in a business integration scenario.
Let me know if you have any questions in the comments below!
Thanks,
Marty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
13 | |
10 | |
9 | |
8 | |
7 | |
7 | |
7 | |
7 | |
6 |