SAP is a global leader in enterprise resource planning (ERP) software. Beyond ERP, SAP offers a diverse range of solutions including human capital management (HCM), customer relationship management (CRM), enterprise performance management (EPM), product lifecycle management (PLM), supplier relationship management (SRM), supply chain management (SCM), business technology platform (BTP), and the SAP AppGyver programming environment for businesses.
The ballerinax/sap
package provides an HTTP
client for interfacing with APIs across SAP's product suite. This client
comes with built-in SAP system-compliant CSRF token authentication.
In this guide, we'll be utilizing the S/4HANA
Sales Order API to showcase the capabilities of the SAP Client.
- Sign in to your S/4HANA dashboard.
-
Under the
Communication Management
section, click on theDisplay Communications Scenario
title. -
In the top right corner of the screen, click
New
. -
Give a system id.
-
Give the hostname as your S/4HANA hostname.
-
Add
Users
forInbound Communication
. -
Select the
Authentication Method
andUser
. -
Click Save.
-
Under the
Communication Management
section, click on theDisplay Communications Scenario
title. -
In the search bar, type
Sales Order Integration
and select the corresponding scenario from the results. -
In the top right corner of the screen, click on
Create Communication Arrangement
. -
Enter a unique name for the arrangement.
-
Choose an existing
Communication System
from the dropdown menu and save your arrangement. -
The hostname (
<unique id>-api.s4hana.cloud.sap
) will be displayed in the top right corner of the screen.
To use the sap
connector in your Ballerina application, modify the .bal
file as follows:
Import the sap
module.
import ballerinax/sap;
configurable string hostname = ?;
configurable string username = ?;
configurable string password = ?;
sap:Client sapClient = check new (string `https://${hostname}/sap/opu/odata/sap/API_SALES_ORDER_SRV`, {
auth: {
username,
password
}
});
Now, utilize the available connector operations.
json salesOrderList = check sapClient->/A_SalesOrder();
bal run
The sap
connector provides practical examples illustrating usage in various scenarios. Explore
these examples, covering use cases
like accessing S/4HANA Sales Order (A2X) API.
- Send a reminder on approval of pending orders -
This example illustrates the use of the
sap:Client
in Ballerina to interact with S/4HANA APIs. Specifically, it demonstrates how to send a reminder email for sales orders that are pending approval.
The Issues and Projects tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library parent repository.
This repository only contains the source code for the package.
-
Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources:
Note: After installation, remember to set the
JAVA_HOME
environment variable to the directory where JDK was installed. -
Download and install Ballerina Swan Lake.
-
Download and install Docker.
Note: Ensure that the Docker daemon is running before executing any tests.
Execute the commands below to build from the source.
-
To build the package:
./gradlew clean build
-
To run the tests:
./gradlew clean test
-
To build the without the tests:
./gradlew clean build -x test
-
To run tests against different environment:
./gradlew clean test -Pgroups=<Comma separated groups/test cases>
Tip: For detailed information, please refer to the Tests_README document.
Groups Environment mock Mock server sap SAP S/4HANA API -
To debug package with a remote debugger:
./gradlew clean build -Pdebug=<port>
-
To debug with the Ballerina language:
./gradlew clean build -PbalJavaDebug=<port>
-
Publish the generated artifacts to the local Ballerina Central repository:
./gradlew clean build -PpublishToLocalCentral=true
-
Publish the generated artifacts to the Ballerina Central repository:
./gradlew clean build -PpublishToCentral=true
As an open-source project, Ballerina welcomes contributions from the community.
For more information, go to the contribution guidelines.
All the contributors are encouraged to read the Ballerina Code of Conduct.
- For more information go to the
sap
package. - For example demonstrations of the usage, go to Ballerina By Examples.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.