Salesforce to S/4 HANA Integration with Ballerina: Part 2

Niveathika Rajendran
Ballerina Swan Lake Tech Blog
2 min readJul 16, 2024

This is part of a series on implementing Salesforce to S/4HANA integration in Ballerina. To start from the beginning, go to Part 1.

In this part, we’ll use the data gathered from Salesforce to create a Sales Order in S/4HANA.

S/4HANA API

We’ll be using the Sales Order (A2X) ODATA API to create the Sales Order. The SAP Setup Guide in the Ballerina documentation provides detailed instructions for setting up this API in S/4HANA.

Ballerina S/4HANA Sales Order Connector

When looking up the API in the Business Accelerator Hub, note the service name ‘API_SALES_ORDER_SRV’ in the URL. This unique name identifies the API within SAP.

Use the service name to look up the ballerina package for the Sales Order API in Ballerina Central,

Step 1: Import and Initialise the SAP S/4HANA Sales Order Client

First, import the ‘sap.s4hana.api_sales_order_srv’ connector and initialise the client.

Step 2: Create a Sales Order

We will use the ‘createA_SalesOrder()’ function from the ‘sap.s4hana.api_sales_order_srv’ package.

Step 3: Test the Integration

You can find the complete code in module-ballerinax-sap.s4hana.sales repository.

Now it’s time to test the code!

  1. Add the credentials to ‘Config.toml’.
  2. Run the example:
bal run

When you close an opportunity on Salesforce, you should see the logs in the terminal where you are running the Ballerina code.

Similarly, in S/4HANA, you should see the Sales Order created with the specified ID.

Conclusion

You’ve successfully completed the integration journey from Salesforce to S/4HANA using Ballerina. We hope you found this guide useful. Stay tuned for more tutorials and examples!

Feel free to leave your comments and questions below!

--

--