For a project we needed to connect to a S/4HANA Cloud 2408 system to extract purchase orders and items. While the documentation for the SAP OData connector is comprehensive, thought it would be good to share detailed steps for others facing this challenge.
This assumes that you have access to a S/4HANA system and that you have been assigned the relevant roles (BR_ADMINISTRATOR & BR_PURCHASER). The first step is to use the SAP Business Acceleration Hub to find the API you need (in our case the purchase orders).
The purchase order API for S/4HANA Cloud Public Edition can be viewed here. The next step is to configure the communication user, communication system and scenario arrangement using the Communication Management page in your S/4HANA Cloud system:
Test the API using the API Hub (using the communication user you just set up) - you will get the URL for the OData service, open it in a separate browser window and add the $metadata suffix - this will return the service definition document. The URL would look similar to this: https://XXXXX/sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/$metadata
Save this file for use in the next step using the save as functionality in the browser.
The next step is to generate the schema for our Mendix app, use the following application provided by Mendix: https://sap-model-creator.home.mendix.com/ - select OData as the source and upload the XML file:
Download the .mpk file:
Now we can finally get to the Mendix application part:
Create a new application and add the SAP OData Connector from the marketplace (this will provide additional functionality that we need in the Microflows). Now import the .mpk file you downloaded from the previous step:
This will then build the purchase order domain model based on the OData definition.
Now we need to create a Microflow to fetch the data from the OData service.
These steps are available from the OData connector module that we imported. Add the communication user and password to the basic authentication step. In the Get list step add the OData query string based on your specific needs and return a list based on the entity you require. In our case we wanted a list of purchase orders.
Note that we return a list based on the PurchaseOrder_Type from the domain model. This can then be used to display a grid on a Page:
The Microflow would need to be enhanced to improve caching, user management (via tokens) etc - but this shows how quickly we can import SAP data into a Mendix Application!
Hope this helps!
Warren