Consuming an External Service From SAP S/4HANA

Objectives

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:

  1. 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.
  2. 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

  1. Get familiar with the Service Center.

    1. Navigate to the Storyboard tab of SAP Business Application Studio.

    2. Find the External Resources tile, and choose the + icon to add a new external data model.

    3. The Service Center side panel will open on the left side of the window, where you should find the SAP S/4HANA Business Partner API. Navigate to SAP Business Accelerator HubSAP S/4HANA Cloud, public editionSAP S/4HANA Cloud, public editionBusiness Partner (A2X).

      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.

    4. 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

  1. Add a data model.

    1. Choose the Add External Data Model button on the top right of the screen.

      This imports the service information into your cloud application. Then, you will navigate back to the Storyboard.

    2. Find the Services tile, and choose the + icon to add a new entity to your service.

    3. In the pop-up, as Projection Type select BusinessPartnerA2X.A_BusinessPartner.

    4. Make sure Enable Draft editing is NOT selected.

    5. Choose OK.

Task 3: Add the Business Partner Entity to Your Application Service

Steps

  1. Add a relationship.

    Use the following data:

    FieldValue
    TypeAssociation
    Multiplicityto-one
    Namesupplier
    Target EntityBusinessPartnerA2X.A_BusinessPartner

    1. Go back to the Storyboard tab and find the Data Models tile.

    2. Choose the entry Risk Management within the Data Models tile, followed by Open in Graphical Modeler.

    3. Find the entry Risks in the Graphical Modeler. Choose the header of the table.

    4. Choose the Add a relationship icon in the menu on the right.

    5. 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.

    6. Enter the data from the table above and choose Create.

Task 4: Configure an SAP Business Accelerator Hub Destination

Steps

  1. 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:

    FieldValue
    Nameapihub_sandbox
    TypeHTTP
    DescriptionSAP Business Accelerator Hub - Sandbox end point
    URLhttps://sandbox.api.sap.com
    Proxy TypeInternet
    AuthenticationNoAuthentication
    1. Go back to your subaccount in the SAP BTP Cockpit. (For more information see: SAP BTP Cockpit)

    2. Navigate to ConnectivityDestinations.

    3. Select Create Destination.

    4. Enter the values from the table above.

  2. Add properties.

    Use the following data:

    FieldValue
    HTML5.DynamicDestinationtrue
    URL.headers.ApiKey(your personal key – see below)
    WebIDEEnabledtrue
    WebIDEUsageapihub_sandbox

    1. Choose the New Property button on the right side.

    2. 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.

    3. In your browser, open a new tab.

    4. in this new tab, login to SAP Business Accelerator Hub.

    5. Under your name in the upper right corner, you will find a link to settings.

    6. Under API Settings, choose the Show API key button. Copy the key.

    7. Go back to the other browser tab.

    8. Paste the API.key into the corresponding field.

    9. Make sure that Use default JDK truststore is checked.

    10. Save your settings.

Result

You have integrated an external service API from an SAP S/4HANA system to your application.

Task 5: Select Attributes of the Business Partner Entity

Steps

  1. Select relevant attributes.

    Your application does not need all the fields the Business Partner Entity offers from the API Business Partner (A2X). Therefore, in your service, you will use a selection.

    The following attributes are important for your app:

    • BusinessPartner
    • Customer
    • Supplier
    • BusinessPartnerCategory
    • BusinessPartnerFullName
    • BusinessPartnerIsBlocked
    1. Go back to the Storyboard.

    2. Find the Services tile.

    3. Select the entry A_BusinessPartner. Choose Open in Graphical Modeler

    4. Choose the header of the entity A_BusinessPartner. Choose Show Details.

      The menu opens on the right side of the screen.

    5. 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

      Your selection is reflected automatically in the graphical modeler.

Practice System

Log in to track your progress & complete quizzes