Skip to Content

8 - Create Action to Get Data from SAP S/4HANA Cloud

Create an action project for defining the API call for retrieving additional data about the business partner, who ID was sent in the event.
You will learn
  • How to create an action (for calling APIs)
  • How to add an action into your process
  • How to configure an action
  • How to work with the data returned by the action
thecodesterDaniel WroblewskiApril 20, 2025
Created by
thecodester
March 11, 2025
Contributors
ajmaradiaga
thecodester

Prerequisites

IT administrators can create “actions” to expose backend APIs to developers of processes or apps (using SAP Build Apps).

From within a package of APIs, actions let the admin expose only the APIs that are meaningful to the developers, and to select a subset of the input and output parameters to make complex APIs easier to use.

Actions specify the details of the API call, but do not specify a backend system. The developer of the process or app will later – during design time – assign the appropriate destination to the action.

  • Step 1
    1. Open SAP Build, and click Actions.

      Open Actions
    2. Click Create.

      Scroll down and select SAP Business Accelerator Hub.

      SAP Business Accelerator Hub

      Enter BusinessPartner in the search.

      Business partner search

      Select Business Partner (A2X) from SAP S/4HANA Cloud Public Edition.

    3. The next screen just shows all the API calls inside this API package, for your information.

      Review APIs

      Click Next.

    4. Now you can name the action.

      Name action

      Keep the defaults, and click Create.

      The newly created action opens, again showing all the OData calls. But now you can select which ones to include in your action.

    5. In the search, enter Retrieves business partner data.

      Open the Business Partner node, and select the /A_BusinessPartner(‘{BusinessPartner}’) API call.

      Select API

      Click Add.

      You now get the action where you can modify the inputs and outputs.

      Action opened
    6. Click Output.

      Check the d node, and then expand it.

      Select outputs

      Uncheck the following fields (it might help to sort by Key):

      Sort
      • BusinessPartner
      • BusinessPartnerGrouping
      • CreationDate
      • FirstName
      • LastName
      • NameCountry

      Scroll back to the top and click Remove and then confirm Remove.

      Remove outputs

      You should be left with just a few fields in the output.

      Outputs
    7. Click Test.

      Select Manual under Host.

      For the URL, enter:

      URL
      Copy
      https://s4-mock-server-with-bp-created-events.cfapps.eu10.hana.ondemand.com/sap/opu/odata/sap/API_BUSINESS_PARTNER
      
      Set up test

      Set the authentication to Basic Authentication and then enter the user and password distributed in the CodeJam by your instructor.

      Add credentials
    8. For the BusinessPartner, input the ID for the business partner you created (or enter this ID: 1003769).

      Click Test.

      You should get data from the backend.

      Test successful
    9. Click Save.

      Save action

      Click Release, then click Release to confirm.

      Release action

      Click Publish, and then click Publish to confirm.

      Publish action
  • Step 2

    In the action test, we supplied the URL and credentials, but this was just for the test. In order to use in production, we want to use a destination – a connection defined in the SAP BTP cockpit to a backend system.

    Destinations can then be used seamlessly in applications and processes to connect to systems, without needing to know the connection details and using all types of sophisticated authentication schemes.

    1. Download the destination template.

      Click Destination template, and then click the download button.

      Download destination
    2. Go to the SAP BTP cockpit for your subaccount.

      You can always return to your trial account cockpit by going to https://account.hanatrial.ondemand.com/ and then opening your subaccount.

      Click Connectivity > Destinations.

      Import destination

      Click Import Destination, and select the file you downloaded.

    3. Enter the password distributed in the CodeJam by your instructor.

      Click Save.

      Save destination
    4. Click Check Connection, and you should get a 200 status code.

      Test destination
  • Step 3

    You created a destination, but you must let SAP Build Process Automation know that you want to allow it to be used in deployed processes.

    1. In the main SAP Build page, click Control Tower.

    2. Click Destinations.

      Add destination to Control Tower
    3. Click Add.

      Click Add

      Select the S4HANA_Badges destination.

      Select destination

      Click Next.

      Keep All Environments, and click Add Destination.

      Destination added

    The destination should now appear in the list of destinations that can be used with your processes.

  • Step 4
    1. Go back to your process project.

      Make sure you are in the Editable version.

      Open project
    2. Under the trigger, click the plus sign, +.

      Add step

      Select Action.

      Select Action

      Select Browse All Actions.

      Browse All Actions

      Click Add next to your action. To help you find the right action, you can see the name of the acttion project.

      Add action

      The action is added to the process.

    3. With the action selected and the process panel on the right open, find the Destination Variable field.

      Click Select a Destination Variable, then click Create Destination Variable.

      Add destination variable

      For the identifier, enter BPdest.

      Click Create.

      Destination variable added
    4. In the Inputs tab, click inside the BusinessPartner field.

      Select Process Inputs > data > BusinessPartner.

      Bind business partner
    5. Save the process by clicking Save (upper right).

  • Step 5

    Now that we’ve retrieved the data, we want to display it in the approval form. You will add a field to display the business partner’s country and grouping.

    1. On the Badge Approval form, click the three dots and select Open Editor.

      Open form editor
    2. Click the Text field on the left twice, which adds 2 new text fields at the end of the form.

      Add text fields
    3. Set the 2 fields as follows:

      Field Name Settings
      Country Make the field Read Only
      Grouping Make the field Read Only

      Click Save.

      Text fields added
    4. Back in the process, select the Badge Approval form.

      Open the Inputs tab.

    5. Bind the 2 new inputs as follows:

      Field Binding
      Country Retrieve business partner > result > Business Partner > Ctry/Reg. for Format
      Grouping Retrieve business partner > result > Business Partner > Grouping

      Click Save.

      Fields bound
  • Step 6
    1. Click Release.

      Release

      Click Release.

      Note that after releasing, you are still inside the editable project, not the released version.

    2. Click Show project version (upper left).

      SHow new release

      This will take you to the released version of your project, so you can deploy it.

    3. Click Deploy.

      Deploy

      Select the Public environment.

      Select Upgrade – as you already have a version deployed.

      You get a message that your deployment will update the existing trigger.

      Triggers

      Click Deploy.

      You now get a new dialog to select values for all the environment variables you created for this project. In this case, you created a destination variable for your action, in order to select the destination for connecting to your backend system.

      Destinations

      Select your S4HANA_Badges destination, and then click Deploy.

  • Step 7
    1. Go back to the Create Business Partner app we provided to you.

      Business partner app
    2. Enter the following:

      Field Value
      First Name Anything you want
      Last Name Anything you want
      Country Select one of the countries
      SAP Community Username Your user name in the SAP Community

      IMPORTANT: You set up your REST Delivery Point to publish only events that contain your community user. So you need to provide your user in order for the event to be delivered to your SAP BTP tenant and to trigger your process.

      Add business partner

      Click Create.

      Your business partner is created.

    3. Check that the event was received into SAP Build by going to Monitoring (in the main SAP Build page).

      Click Acquired Events.

      Acquired events

      Click Business Events. You should see an event created for your new business partner, including the business partner ID that you saw when you created it.

      Business events
  • Step 8
    1. In SAP Build, click Monitoring.

    2. Click the Processes and Workflow Instances tile.

      Process and Workflow Instances
    3. Click on the process instance to see its details.

      In the Logs area, you will see the step where the action was started and completed.

      Action steps

      In the Context area, you will see data received from the event, as well as the data retrieved from the action call to our business partner.

      Data from business partner
    4. In your Inbox, see the approval form. It now contains the country and grouping, which you retrieved from the SAP S/4HANA Cloud backend.

      Data in the approval form

    Feel free to finish the process by approving the badge and then acknowledging the notification, as you did in the previous tutorial.

  • Step 9

    Things to Ponder

    What is the advantage of creating actions?

    When creating an action, why configure it? Why not leave all the API calls and all the inputs/outputs?

    What is the purpose of a destination variable?

    What is another advantage of using actions (related to SAP Build Apps, see this news item)?

Back to top