Consuming an External Service From SAP S/4HANA

Objectives
After completing this lesson, you will be able to:

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 API Business 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 – by using the instructions provided below, you can perform the steps in your SAP BTP account.
  2. Platform Simulation – follow the step-by-step instructions within the simulation.
Note
We strongly recommend to perform 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 Home tab of SAP Business Application Studio.

    2. Find the External Data Model 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 API BUSINESS HUBSAP S/4HANA CloudSAP S/4HANA CloudBusiness Partner (A2X).

      Note
      In case you see a login window enter the same user you use to login to SAP API Business Hub.
      Note

      In case the Service Center side panel doesn’t open, please select the Service Center icon from the menu on the left side of SAP Business Application Studio.

    4. Here, you can get all the information on the selected Business Partner API, 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.

    Use the following data:

    FieldValue
    NameA_Supplier
    TypeBusinessPartnerA2X.A_BusinessPartner
    PropertiesBusinessPartner, BusinessPartnerFullName, BusinessPartnerIsBlocked

    1. Choose the Add External Data Model button on the top right button of the screen. This imports the service information into your cloud application. Then, you will navigate back to the Application Homepage.

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

    3. In the pop-up, enter the data from the table above.

    4. Choose Create.

    5. Go back to the Home tab and find tile Data Models. Choose the entry Risks.

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

Steps

  1. Add a relationship.

    Use the following data:

    FieldValue
    RelationshipAssociation
    Relationship Typeto-one
    Property Namesupplier
    Target Entity TypeBusinessPartnerA2X.A_BusinessPartner

    1. Choose the icon to Add Relationship of the risk entity. Choose a place anywhere on screen to configure relationship.

    2. In the pop-up, enter the data from the table above.

    3. Choose Create.

Task 4: Configure an SAP API Business 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 SAP API Business Hub.

    Use the following data:

    FieldValue
    Nameapihub_sandbox
    TypeHTTP
    DescriptionSAP API Business 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 New 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 API Business 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 API Business 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.

Save progress to your learning plan by logging in or creating an account

Login or Register