In the previous chapter you have created an integration package and an integration flow that can be called using a REST API.
In this chapter, you will refine the integration flow so that it also writes the data in an SAP S/4HANA system.
Hence, once an order is created from any system using the REST API, the associated maintenance contract will be written into the maintenance contract database and in parallel a purchase order will be created in the ERP.
Access the Cloud Integration service
Make sure you are inside the SAP Integration Suite - Integration and APIs section, otherwise access the Lobby and navigate to the Design section in the left-hand menu.
Extend the existing integration flow
In this exercise, you will extend the integration flow from chapter 2 to write the order in the S/4 HANA system - in parallel to the entry of the maintenance contracts database.
Navigate to the Design section of the Cloud Integration service.
Locate your integration package (“Orders_”) and open it.
Navigate to Artifacts section and Open the integration flow (“ProcessOrder_”) by clicking on it.
Click on the Edit button to start making changes.
We will now add a representation of the S/4 HANA system into our integration flow to send the sales order to it.
In the integration flow editor, in the palette (i.e. toolbar), click on the Participants icon and select Receiver.
Position the new receiver at the right of your integration flow.
Rename the receiver into S4HANA by changing its Name in the properties panel at the bottom of the editor.
Because we now have multiple receivers, it is a good idea to also rename the first receiver (PostgreSQL) into something more meaningful.
Click on the first Receiver (connected through JDBC) and change its name into PostgreSQL.
We will now add another end step of our integration flow. This end message step allows you to send data to a receiver system after the integration flow processing is finished.
Note
the response of the system is sent back to the integration flow caller automatically when using this step. If you wanted to check the response of the system, you would rather use a request-reply step.
In the palette, click on Events and select End message.
Position the end message flow step under the existing one, left from your S/4HANA receiver.
We will now connect the end of the integration flow to the S/4HANA receiver using the OData v2 adapter.
Click on the end flow step you just added, select the arrow and click on the S/4HANA receiver.
Select OData as adapter type and OData v2 as message protocol.
We will now configure the communication with the S/4HANA system. This is done through the properties of the adapter.
Click on the arrow between the end flow step and the S/4HANA receiver.
Maximize the properties pane using the button at the bottom right corner of your screen.
Configure the Connection as follows:
Address:
Proxy Type: Internet
Authentication: Basic
Credential name: AC_S4_OnPrem
CSRF Protected: uncheck
Reuse Connection: check
The configuration should look like this:
Now click on the Processing tab
Set the Operation Details to POST
Click on Select next to the Resource Path input field to open the OData wizard
In the first step, notice that all field are prepopulated with the ones you have entered in the Connection tab.
Click on Step2 and configure the operation as follows:
Operation: Create (POST) (defaulted)
Sub Levels: 1
Select Entity: A_SalesOrder
Generate XML Schema Definition: checked
Select the following fields:
SalesOrderType
SalesOrganization
DistributionChannel
OrganizationDivision
SoldToParty
PurchaseOrderByCustomer
to_Item/Material
to_Item/RequestedQuantity
Deselect the foreign keys
SalesOrder (at the very top)
to_Item/SalesOrder
to_Item/SalesOrderItem
Click on Finish.
The configuration of your adapter should look like this:
Click on Save in the integration flow editor.
Define the mapping
We will now map the correct fields from the incoming payload onto the payload expected by the S/4HANA system.
Note that we will use:
an OpenAPI specification file for the incoming message
the XSD message structure we have just created from the OData adapter
In the palette, click on Mapping and select Message Mapping.
Position the message mapping flow step to the left of the End flow step you created previously.
Connect the mapping flow step to the end flow step.
Note that there are 2 different approaches for this tutorial step.
You can do the first approach, Import the Mapping to save some time.
You can instead do the second approach, Manual steps, which will teach you about how to create such mappings.
In the interest of time, you will follow the Import the Mapping approach. However, the Manual steps approach is available as an optional exercise.
Click on an empty spot of your integration flow canvas.
Click on References
Click on Add
Click on Mapping
Click on Message Mapping >
Select the ZIP file you have downloaded and click Add >
Click on your Message Mapping 1 flow step
Click on the Processing tab.
Click on the Select button.
Select the mapping you just added and click OK >
Orchestrate the integration flow
We will now finish the configuration of the integration flow by parallelizing the execution of the communication with the Azure PostgreSQL and the S/4HANA system.
Click on the Routing icon of the palette, select Multicast and then Sequential Multicast.
Click on the line between the Start and Converter flow steps. The line should highlight green.
Select the Multicast flow step and then drag and drop the arrow of the contextual menu to the message mapping created previously.
Beautfy your integration flow by using the blue dots and the anchors of the flow steps.
Your integration flow should now look something like this:
Save and Deploy your integration flow so that we can test it.
Test the integration flow
Reuse the API Call you made in the previous chapter in order to test the new integration flow. The endpoint has not changed so just execute the request from Postman (or any other tool of your choice).
Still keep in mind that the order reference must be unique. Replace PXXXXXX-*** with
If everything goes fine, the response of the integration flow should be a 201 code as depicted below.
Note: Please do note down the Sales Order Number as we will be using it in exercise 4.
Check the data in PostgreSQL Maintenance Contract Database using UI exposing its data. Lobby. Filter by your Order Reference Number.
Note
In case you did not have time to go through all steps, you can also import the integration flow from the
Congratulations! You are now ready for the next lesson!