Skip to main content

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.

Add Connection palette open with the search field before any selectionAdd Connection palette open with the search field before any selection

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 : ConnectionConfig record with Basic Authentication credentials; switch to Expression and enter {auth: {username: sapS4HanaUsername, password: sapS4HanaPassword}}
  • Hostname : SAP S/4HANA API hostname; bind to the sapS4HanaHostname configurable variable
  • Connection Name : Keep the default apiMaterialStockSrvClient
SAP Material Stock connection form filled with configurable variables before savingSAP Material Stock connection form filled with configurable variables before saving

Step 3: Save the connection​

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

Design canvas showing the saved apiMaterialStockSrvClient connectionDesign canvas showing the saved apiMaterialStockSrvClient connection

Step 4: Set actual values for your configurables​

  1. In the left panel, select Configurations.
  2. 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​

  1. On the automation canvas, select the + button to add a step.
  2. Expand the apiMaterialStockSrvClient connection under Connections.
apiMaterialStockSrvClient connection expanded in the node panel showing the available operationsapiMaterialStockSrvClient connection expanded in the node panel showing the available operations
  1. Select List A Material Stocks (listA_MaterialStocks) and configure it:
  • $top : Under Advanced Configurations, set to 10 to limit the results to the first 10 records
  • Result : Set the result variable name to result
listA_MaterialStocks operation form with $top set to 10listA_MaterialStocks operation form with $top set to 10
  1. Select Save to add the operation to the flow, then add a Log Info step after it that logs result.toJsonString() in Expression mode.
Completed automation flow with the listA_MaterialStocks operation and a log stepCompleted automation flow with the listA_MaterialStocks operation and a log step

Try it yourself​

Try this sample in WSO2 Integration Platform.

Deploy to Devant

View source on GitHub

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.

  1. POS Integration with S/4HANA - Check real-time material stock and create reservation documents in S/4HANA from point-of-sale orders.

  2. Warehouse Automation through S/4HANA Integration - Digitize paper delivery notes with OCR and create material documents in S/4HANA from the extracted data.