Embedded Steampunk is SAP's strategic ABAP Cloud development model available on S/4HANA Public Cloud (and Private Cloud/on-premise with specific releases). It allows developers to build cloud-ready extensions directly on the S/4HANA application server using a restricted, cloud-optimized ABAP language and a defined set of released APIs and extension points.
Key characteristics include:
Cloud-Optimized ABAP: A subset of ABAP focused on cloud principles.
Released APIs: Interaction with SAP functionalities is done exclusively through released APIs (like Business APIs on SAP Business Accelerator Hub) or released extension points.
DevOps Ready: Designed for agile development and integration into DevOps pipelines.
On-Stack: Development happens directly within the S/4HANA system instance.
The Business Partner API is a fundamental public API in S/4HANA, allowing external systems or extensions to create, read, update, and delete Business Partner data (including Customers and Suppliers). It is available as an OData service.
You can find detailed information and the service definition on the SAP Business Accelerator Hub:
This is your primary reference for the API's structure, entity sets (like A_BusinessPartner), properties, and available operations.
To call any external or internal API from your on-stack ABAP code in Embedded Steampunk, you must configure the communication using the standard framework involving:
Communication User: Represents the technical user making the call.
Communication System: Represents the remote system or endpoint being called.
Communication Arrangement: Links a Communication Scenario (defining a set of services) to a Communication System and specifies the technical details like authentication method and service URLs.
Communication Scenario: A pre-defined template grouping related inbound and/or outbound services (e.g., SAP_COM_0008 for Business Partner Integration).
For calling a public API within the same S/4HANA tenant, the Communication System will logically represent your own system's API endpoint.
All communication configuration is done in your Customizing Starter tenant using Fiori apps.
This user will be used for authenticating the outbound call your ABAP code makes.
Open the "Maintain Communication Users" app.
Click "New".
Enter a User Name (e.g., BP_API_CALLER).
Enter a Description.
Provide a Password and confirm it. Note this password down securely.
Click "Create".
This system logically represents your own S/4HANA tenant's API endpoint from the perspective of your outbound call.
Open the "Communication Systems" app.
Click "New".
Enter a System ID (e.g., MY_S4_TENANT_API).
Enter a System Name.
Under "General Settings", ensure the Host Name is the API endpoint hostname of your S/4HANA tenant (e.g., myXXXXXX-api.s4hana.cloud.sap).
Under "Users for Outbound Communication", click "+".
Select "Authentication Method" as "User ID and Password".
Enter the User Name of the Communication User you created in Step 1.
Enter the Password for this user.
Click "Create".
Click "Save".
This is the crucial part for calling an API within the same system. You need two arrangements based on SAP_COM_0008:
One to define how external systems (or your system acting as an external caller) can call inbound to the API.
One to define how your system is configured to call outbound to the API endpoint.
Arrangement 1: Inbound Configuration (Defines how to call IN)
This arrangement is necessary for the API endpoint to be active and reachable, and it defines the user and authentication for incoming calls.
Open the "Communication Arrangements" app.
Click "New".
Select the Communication Scenario: SAP_COM_0008 (Business Partner, Customer, and Supplier Integration).
Enter an Arrangement Name (e.g., SAP_COM_0008_INBOUND).
Click "Create".
In the arrangement details:
Under "Communication System", select the Communication System you created in Step 2 (e.g., MY_S4_TENANT_API).
Under "Inbound Communication":
Ensure the User Name is the Communication User you created in Step 1.
Set the Authentication Method to "User ID and Password".
Review the Inbound Services list. You should see the "Business Partner (A2X)" OData service listed with its Service URL and Service ID (API_BUSINESS_PARTNER).
Under "Outbound Communication": This section is less critical for this specific arrangement's purpose.
Click "Save".
Ensure the Status is "Active".
Arrangement 2: Outbound Configuration (Defines how to call OUT)
This arrangement defines the specific configuration used by cl_http_destination_provider=>create_by_comm_arrangement in your ABAP code to make an outbound call to the API.
Open the "Communication Arrangements" app again.
Click "New".
Choose Newly created Communication Scenario ( note : Create New Communication Scenario: ZZZXXXXYY and provide the Business Partner API as Outbound Service over there ).
Enter a different Arrangement Name (e.g., SAP_COM_0008_OUTBOUND).
Click "Create".
In the arrangement details:
Under "Communication System", select the same Communication System you used for the first arrangement (e.g., MY_S4_TENANT_API).
Under "Inbound Communication": This section is not the primary focus here.
Under "Outbound Communication":
Ensure the User Name is the same Communication User you created in Step 1.
Set the Authentication Method to "User ID and Password".
Crucially, find the entry for the Service ID API_BUSINESS_PARTNER. This entry must exist and be configured with the correct URL (which should be automatically populated based on the scenario and system) and the authentication method.
Click "Save".
Ensure the Status is "Active".
Why the Same Username and Password are Crucial for Basic Authentication:
When your ABAP code initiates the outbound call using the second Communication Arrangement, the system uses the Communication User and password configured in that arrangement's Outbound Communication section for the specified service ID. This user and password are sent as basic authentication credentials to the target endpoint.
Since the target endpoint is the same S/4HANA tenant's API, and that endpoint is configured to accept inbound calls using the first Communication Arrangement, the credentials sent by the outbound call are validated against the user configured for inbound calls in the first arrangement.
Therefore, for basic authentication to succeed in this "calling within the same system" scenario, the Communication User and password configured for Outbound Communication in the second arrangement must match the Communication User and password configured for Inbound Communication in the first arrangement. If they differ, the inbound authentication check will fail, leading to errors (like the SAML redirection ).
Once the Communication Arrangements are set up, your ABAP code in Embedded Steampunk can use the standard OData client proxy or HTTP client framework to call the API.
You would typically use cl_http_destination_provider=>create_by_comm_arrangement with the details of your outbound-focused Communication Arrangement (SAP_COM_0008, MY_S4_TENANT_API, API_BUSINESS_PARTNER) to get the HTTP destination and then create an HTTP client or OData client proxy.
DATA: lo_http_client TYPE REF TO if_web_http_client,
lo_req TYPE REF TO if_web_http_request,
lo_resp TYPE REF TO if_web_http_response,
lv_status TYPE i,
lv_response TYPE string.
TRY.
"1. Create an HTTP destination using your communication arrangement.
DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = ' ' " The communication scenario defined in the system
comm_system_id = ' ' " For same S/4HANA Public Cloud system
service_id = ' ' ). " Service ID as configured (Outbound Service Name )
"2. Create the HTTP client – basic auth is handled by the arrangement.
lo_http_client = cl_web_http_client_manager=>create_by_http_destination( lo_destination ).
"3. Prepare HTTP headers.
lo_req = lo_http_client->get_http_request( ).
lo_req->set_header_fields( VALUE #(
( name = 'Accept' value = 'application/json' )
( name = 'Content-Type' value = 'application/json' ) ) ).
lo_req->set_uri_path( '/A_BusinessPartner(''0010000000'')' ).
"6. Execute the GET request using the client, passing the method.
lo_resp = lo_http_client->execute(
i_method = if_web_http_client=>get ).
data(lv_status1) = lo_resp->get_status( ).
lv_response = lo_resp->get_text( ).
IF lv_status = 200.
ELSE.
ENDIF.
CATCH cx_root INTO DATA(lx_root).
ENDTRY.
IF lo_http_client IS BOUND.
lo_http_client->close( ).
ENDIF.
Calling public APIs within Embedded Steampunk requires careful configuration of Communication Arrangements and Communication Systems. While the concept is similar to calling external APIs, calling an API hosted within the same tenant necessitates understanding the interplay between inbound and outbound configurations. By creating two Communication Arrangements based on the same scenario and system, and ensuring the same Communication User with basic authentication is configured for both inbound and outbound communication for the relevant service, you can successfully enable your on-stack ABAP extensions to interact with public APIs like the Business Partner API. This setup ensures that the system correctly resolves the destination and authenticates the call using the configured basic authentication credentials.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 |