After completing this lesson, you will be able to consume an external service from SAP S/4HANA
Consume an External Service from SAP S/4HANA
Business Scenario
In this lesson, you will expand your application with an API, which allows to get data from your SAP S/4HANA back-end system. This enables the application to use data directly from the back-end system.
In this exercise, you will perform the following tasks:
Get familiar with the Service Center in SAP Business Application Studio.
Add the Business Partner API to the application.
Add the Business Partner entity to your application service.
Configure an SAP Business Accelerator Hub Destination.
Prerequisites
You have successfully completed the exercise Define Services.
Note
Note, that some of the services that this learning journey links to, can incur costs.
If you are concerned about charges, you can opt to skip the corresponding exercises and watch the simulation instead.
Exercise Options
You can perform this exercise in two ways:
Live Environment / Practice System: you can perform the steps provided below, either in your SAP BTP account or you use the "Practice System Access" provided below.
Simulation: follow the step-by-step instructions within the simulation.
Note
You can try out this exercise in the practice system below. Open the system by choosing the appropriate buttom on the end of this exercise.
Note, that the practice system access only covers access to the SAP Business Application Studio. When deploying to an SAP BTP runtime or consuming other SAP BTP services, you have to use an SAP BTP Trial Account, Free-Tier, or an Enterprise Account.
Note
We recommend performing the steps in the live environment first.
The following simulation reproduces the full exercise execution:
Task 1: Get Familiar With the Service Center in SAP Business Application Studio
Steps
Get familiar with the Service Center.
Navigate to the Storyboard tab of SAP Business Application Studio.
Find the External Resources tile, and choose the + icon to add a new external data model.
The Service Center opens in a new tab.
On the left side of the window, select Service.
Choose SAP Business Accelerator Hub as Provider, choose SAP S/4HANA Cloud Public Edition as Product, and SAP S/4HANA Cloud Public Edition as Package.
Note
In case you see a login window enter the same user you use to login to SAP Business Accelerator Hub.
Note
In case the Service Center side panel doesn’t open, select the Service Center icon from the menu on the left side of SAP Business Application Studio.
A list opens displaying the available services.
Enter Business Partner (A2X) in the search field and select the corresponding service.
Check, that you can get all the information on the selected Business Partner API here, for example:
The service entities and properties.
The OData protocol version.
The service live data coming from the SAP system (in our case from API Hub sandbox).
Task 2: Add the Business Partner API to the Application
Steps
Add a data model.
Choose the Add to Project button in the middle of the screen.
This imports the service information into your cloud application. Then, you will navigate back to the Storyboard.
Choose the entry corresponding to the namespace you created before, for example, RiskManagementService. From the menu that open select Add Service Entity.
In the service.cds screen, as Projection Type select BusinessPartnerA2X.A_BusinessPartner
Make sure Enable Draft editing is NOT selected.
On the Projection tab in the appeared menu, deselect all properties (use all properties), and then select the following ones:
BusinessPartner
Customer
Supplier
BusinessPartnerCategory
BusinessPartnerFullName
BusinessPartnerIsBlocked
Save your changes.
Task 3: Add the Business Partner Entity to Your Application Service
Steps
Add a relationship.
Use the following data:
Field
Value
Type
Association
Multiplicity
to-one
Name
supplier
Target Entity
BusinessPartnerA2X.A_BusinessPartner
Go back to the Storyboard tab and find the Data Models tile.
Choose the entry Risk Management within the Data Models tile, followed by Open in Graphical Modeler.
Find the entry Risks in the Graphical Modeler. Choose the header of the table.
Choose the Add a relationship icon in the menu on the right.
Drop the line to the Risks entity somewhere on the screen and configure the relationship in the menu on the right side of the screen.
Enter the data from the table above and choose Create.
Task 4: Configure an SAP Business Accelerator Hub Destination
Steps
Add a destination in the SAP BTP Cockpit.
Before you use the data from the Business Partner API in SAP Business Application Studio, you must first configure a destination for the SAP Business Accelerator Hub.
Use the following data:
Field
Value
Name
apihub_sandbox
Type
HTTP
Description
SAP Business Accelerator Hub - Sandbox end point
URL
https://sandbox.api.sap.com
Proxy Type
Internet
Authentication
NoAuthentication
Go back to your subaccount in the SAP BTP Cockpit. (For more information see: SAP BTP Cockpit)
Navigate to Connectivity → Destinations.
Select Create Destination.
Enter the values from the table above.
Add properties.
Use the following data:
Field
Value
HTML5.DynamicDestination
true
URL.headers.ApiKey
(your personal key – see below)
WebIDEEnabled
true
WebIDEUsage
odata_gen
Choose the New Property button on the right side.
Except for the entry URL.headers.ApiKey, enter the values from the table above.
For the property URL.headers.ApiKey you have to enter your unique API key from the SAP Business Accelerator Hub. You will get this in the next substeps.