Example
What you'll build
Build an integration workflow that connects to an SAP S/4HANA system and retrieves material stock records. The workflow calls the Material Stock (A2X) API and logs the result as JSON.
Operations used:
- listA_MaterialStocks : Reads material stock records (material and base unit of measure) from the SAP S/4HANA system, returning the first 10 results
Architecture
Prerequisites
- Access to an SAP S/4HANA Cloud system with a communication user assigned to the communication arrangement this connector needs (see the Setup Guide)
Setting up the SAP Material Stock integration
New to WSO2 Integrator? Follow the Create a New Integration guide to set up your integration first, then return here to add the connector.
Adding the SAP Material Stock connector
Step 1: Open the connector palette and search for the connector
Select Add Artifact, then select Connection to open the connector palette. Search for api_material_stock_srv and select the Api_material_stock_srv connector card.

Configuring the SAP Material Stock connection
Step 2: Fill in the connection parameters
Enter the connection parameters, binding each field to a configurable variable:
- Config :
ConnectionConfigrecord with Basic Authentication credentials; switch to Expression and enter{auth: {username: sapS4HanaUsername, password: sapS4HanaPassword}} - Hostname : SAP S/4HANA API hostname; bind to the
sapS4HanaHostnameconfigurable variable - Connection Name : Keep the default
apiMaterialStockSrvClient

Step 3: Save the connection
Select Save Connection. The connection appears under Connections in the project tree and on the design canvas.

Step 4: Set actual values for your configurables
- In the left panel, select Configurations.
- Set a value for each configurable listed below:
- sapS4HanaHostname (string) : The API hostname of your SAP S/4HANA Cloud system, for example,
my123456-api.s4hana.cloud.sap - sapS4HanaUsername (string) : The communication user name
- sapS4HanaPassword (string) : The communication user password
Configuring the SAP Material Stock listA_MaterialStocks operation
Step 5: Add an automation entry point
Select Add Artifact, then select Automation and select Create to add the automation entry point to the canvas.
Step 6: Select and configure the listA_MaterialStocks operation
- On the automation canvas, select the + button to add a step.
- Expand the apiMaterialStockSrvClient connection under Connections.

- Select List A Material Stocks (
listA_MaterialStocks) and configure it:
- $top : Under Advanced Configurations, set to
10to limit the results to the first 10 records - Result : Set the result variable name to
result

- Select Save to add the operation to the flow, then add a Log Info step after it that logs
result.toJsonString()in Expression mode.

Try it yourself
Try this sample in WSO2 Integration Platform.
More code examples
The SAP S/4HANA Inventory Ballerina connectors provide practical examples illustrating usage in various scenarios. Explore these examples, covering use cases like point-of-sale stock reservations and warehouse document automation.
-
POS Integration with S/4HANA - Check real-time material stock and create reservation documents in S/4HANA from point-of-sale orders.
-
Warehouse Automation through S/4HANA Integration - Digitize paper delivery notes with OCR and create material documents in S/4HANA from the extracted data.