Encapsulating the APIs of Remote Systems Using Actions Projects

Objective

After completing this lesson, you will be able to encapsulate remote systems APIs using actions projects

Encapsulation of Remote Systems APIs Using Actions Projects

As many business processes span across a multitude of different systems and applications, a means to interact with these systems and applications is required in the business process management system. In SAP Build Process Automation, you use Actions to accomplish the integration. Application Programming Interfaces (APIs) from the source and target systems to interact with, are encapsulated as Actions within Actions projects. Those Actions projects are then held in an Actions projects library and from there, can be integrated into the business processes. This approach offers various advantages compared to direct API integration into the respective process:

  • There is an abstraction of the API. The process developer does not need to know exactly about technical details of the API.
  • APIs can be adjusted to the process developers needs, only exposing endpoints and data that is required or safe to use by the process developers.
  • Actions can be configured once, and then be reused across different business process projects.
  • Actions projects allow versioning and thus, make it easier to deal with changing process requirements or changing API versions.

As Actions rely on the OpenAPI Specification standard (https://spec.openapis.org/oas/v3.1.0#openapi-specification) for API definition, they aren't limited to APIs from SAP systems, but provide the option to integrate any API that is or can be described in the OpenAPI Specification. A large number of API definitions, especially for but not limited to SAP solutions, can be found in the SAP Business Accelerator Hub.

Note

You'll find additional information on APIs, specifically on SAP Build Process Automation APIs, and how to interact with them on a more technical level in unit API Integration of SAP Build Process Automation.

Actions Editor

The Actions Editor lets you compose multiple Actions from an underlying API into an Actions project. Note that you don't have to include all possible parameters of an API endpoint as parameters in the respective Actions, and you also don't have to include all available response body fields in the response provided through the Action. By that, only information relevant to the business process can be included.

Once your Actions have been defined, the project needs to be released into a version and then published to the Actions library.

After APIs have been encapsulated in an Actions project and published to the library, adding them as action to a process is quite simple. Select the corresponding step type Actions and browse the Actions library. Select the action required in your process, and choose Add. Once the Action step is included in your process, make sure to define its parameters:

  • Destination variable: A process variable that will hold the technical SAP BTP destination name to be used for accessing the underlying API at process runtime. This variable can be filled with a destination name during deployment of the process.
  • Inputs: Mapping of process content to all parameters, that the action requires in order to be performed (for example, the Sales Order Number, when retrieving a Sales Order entry from an SAP S/4HANA system).
  • Outputs: Overview of the Actions call result, as defined in the respective action.

Encapsulate Remote Systems APIs Using Actions Projects

Business Scenario

You and your colleagues are building a process that needs to read Sales Order data from your SAP S/4HANA system and at a later stage, also write Sales Order data back to the system. Now you're faced with the challenge of interacting with that SAP S/4HANA system in the process. As a solution to this challenge, SAP Build Process Automation provides the capability of Actions projects. Your are going to define all the SAP S/4HANA Sales Order API endpoints that shall be used in the process, as Actions in an Actions project. This procedure can also be described as encapsulating the APIs, because you're building a wrapper only around the specifically required API endpoints. By releasing and publishing the Actions project, the actions will be available in an Actions library for consumption within your processes.

To learn more about how to encapsulate remote systems APIs using Actions projects, follow this tutorial.

Exercise Options

To start the exercise, choose Start Exercise in the figure below.

A pop-up opens. You have the following options:

  • Choosing Start: the simulation starts. Follow the simulation to learn how to encapsulate remote systems APIs Using Actions Projects.
  • Choosing Open PDF Document: a PDF opens. Based on the steps described in this document, you can perform the exercise in your own system landscape.

Steps

  1. Re-encapsulate remote systems APIs using Actions projects.

    1. Choose Actions.

    2. Choose Create.

    3. Select the scroll area to scroll down.

    4. Choose SAP Business Accelerator Hub.

    5. Select the scroll area to scroll down.

    6. Choose SAP S/4HANA Cloud Public Edition.

    7. Select the scroll area to scroll down.

    8. Choose SAP S/4HANA Cloud Public Edition.

    9. In the Search field, enter Sales.

    10. Press Enter.

    11. Choose Sales Order (A2X).

    12. Choose View API Documentation.

    13. Select the scroll area to scroll down.

    14. Choose API Specifications.

    15. Choose Download.

      Note

      In the following steps, you will upload the downloaded JSON file to your project, to do this navigate back to your Build Apps tab.
    16. Choose Back.

    17. Choose Integration Sources.

    18. Select the scroll area to scroll down.

    19. Choose Upload API Specification.

    20. Choose Browse Files.

    21. Choose API_SALES_ORDER_SRV.json.

    22. Choose Open.

    23. Choose Next.

    24. In the Project Name field, enter SAP S/4HANA Sales Order Actions.

    25. In the Description field, enter Actions Project to interact with sales order in S/4HANA system.

    26. Choose Create.

    27. Choose SAP S/4HANA Sales Order Actions.

    28. Select the scroll area to scroll down.

    29. Choose Sales Order Header.

    30. Choose Reads the header of a sales order.

    31. Choose Add.

    32. Choose Output.

    33. Choose Select All.

    34. To expand the Key pane, choose the arrow.

    35. Choose Search.

    36. In the Search field, enter Organi.

    37. Clear/uncheck the OrganizationDivison checkbox.

    38. In the Search field, enter distrib.

    39. Clear/uncheck the DistributionChannel checkbox.

    40. In the Search field, enter Total.

    41. Clear/uncheck the TotalNetAmount checkbox.

    42. In the Search field, enter Salesord.

    43. Clear/uncheck the SalesOrderType checkbox.

    44. Clear/uncheck the SalesOrderDate checkbox.

    45. In the Search field, enter Purchase.

    46. Clear/uncheck the UncheckPurchaseOrderByShipToParty checkbox.

    47. In the Search field, enter salesorga.

    48. Clear/uncheck the SalesOrganization checkbox.

    49. In the Search field, enter request.

    50. Clear/uncheck the RequestedDeliveryD checkbox.

    51. Choose Remove.

    52. Choose Remove again.

      Note

      Note that we have now removed all the other non-required keys for the action.
    53. Choose Save.

Result

You have now successfully encapsulated remote systems APIs using Actions projects.

Task 1: Test Actions

Steps

  1. Encapsulate remote systems APIs using actions projects.

    1. Choose Try Out.

    2. Choose Sales Order Header.

    3. Choose Get/A_SalesOrder("{SalesOrder}").

    4. In the Value field, enter 1.

    5. Choose Run.

      Note

      You can review the Request URL, Response Body output below.
    6. Choose Show API Key.

      Note

      The API Key will be included in your Actions input parameters. Keep this tab open as we'll come back to it for the next steps in this exercise.
    7. Choose Copy Key and Close.

    8. Choose Input.

    9. Choose Add.

    10. Choose New Field.

    11. In the Key field, enter APIKey.

    12. Choose Parameter.

    13. Choose header.

    14. In the Value field, enter pGAVlcXDR7tPplcGF02RinSeiT79TYSO.

      Note

      You will find the Label in the Business Accelerator Hub, go back to the tab from where you copied the API key.
    15. Choose Overview.

    16. Select the scroll area to scroll down.

      Note

      Copy the SANDBOX URL and add it to the Values input parameter.
    17. In the Label field, enter https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_SALES_ORDER_SRV.

    18. Select the scroll area to scroll down.

    19. Choose Add.

    20. Choose Test.

    21. Choose Manual.

    22. In the URL field, enter https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_SALES_ORDER_SRV.

    23. In the string value field, enter 1.

    24. Choose Test.

      Note

      The output of Test preview shows the header values of the sales order.
    25. Choose Release.

    26. In the Release Notes field, enter Reads the header of the sales order.

    27. Choose Release.

    28. Choose Publish to Library.

    29. Choose Publish.

      Note

      The Input parameter for sales order is successfully added, you can now navigate to the Lobby to confirm this.
    30. Choose Refresh.

Result

You have now successfully encapsulated remote systems APIs using actions projects.

Log in to track your progress & complete quizzes