Skip to Content

Call Web Services using Destinations in SAP Process Automation

Call Web Services using Destinations to retrieve sales order details from SAP S/4HANA
You will learn
  • How to call Web services using Destinations
Created by
celineaudinsap
August 4, 2022
Contributors
celineaudinsap

Prerequisites

In this tutorial, you will retrieve sales order details for a particular Sales Order from SAP S/4HANA.

  • Step 1

    You need to get access to the Public gateway system. Please Create an Account on the SAP Gateway Demo System.

  • Step 2

    Once you have successfully created an account in the SAP Gateway Demo system, use the credentials and configure the Destination in SAP BTP account. Refer to the Prerequisites to Configure BTP Destinations in SAP Process Automation

  • Step 3
    1. Create a Business Process named Sales Order.

    2. Create an Automation named Get Sales Order Details.

  • Step 4

    You will now build an automation to retrieve sales order details from SAP backend using Destinations configured in SAP BTP.

    1. Under the Automation Details panel, create an Input parameter called Sales Order ID of type String.

      Input parameter Automation
    2. Now drag and drop the activity Custom script.

    3. Choose Edit Script.

    4. Add input and output parameters for the Custom script as shown below.

      Parameter Name Type of parameter Data type
      SalesOrderNumber InputString
      SalesOrderDetails Output Any
    5. Add the code to retrieve the sales order details for a particular sales order.

      let url = "/sap/opu/odata/iwbep/GWSAMPLE_BASIC/SalesOrderSet('" + SalesOrderNumber + "')";
      
      return {
        'method': 'GET',
        'url': url ,
        'responseType':'json', // parse the body of the result as a JSON object
        'resolveBodyOnly':true // get only the body of the response
      };
      
      Custom script
    6. Now link the Input parameter of the automation Sales Order ID to the Input parameter of the Custom script Sales Order Number.

      Input parameter Custom script
    7. Drag and drop the activity Call Web Service with Destination.

    8. Map the parameters as shown below.

      The value of for destination parameter can be maintained after successful completion of the tutorial Create Destination as mentioned in Prerequisites

    9. Choose Save.

      Call Webservice
    10. Now add an activity Log Message.

    11. Link the Input parameter message of the Log Message activity to the Output parameter of the Call Web Service with Destination activity to see the results.

      Log Message
    12. Save the automation.

      The final automation looks as below.

      Automation
  • Step 5

    Refer to the tutorial on how to release and deploy the Process.

    When you deploy the Process, enter the value for the Destination.

    The value for the destination parameter would appear only after successful completion of the tutorial Create Destination as mentioned in Prerequisites.

    Enter the values as shown below.

    Deploy
  • Step 6
    1. Test the automation with the below input data.

      Test Automation
    2. You can see the results of the testing with the sales order details of the sales order you selected.

      Results

      Now the automation is ready and can be added to your process by adding Output parameters for the automation.

    Do we need to create an Environment variable of type Destination to access the destination in the Business Process project?

Back to top