Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
TJe
Product and Topic Expert
Product and Topic Expert

In this tutorial we will create a very basic Action Project for a simple REST API which will return the list of ToDos.
The goal is to cover all the steps necessary to consume Actions in a Process, not to proivde a real Process use case.

This is part of a blog series for Actions:
SAP Process Automation – Consume APIs with <no-code> using Actions.

Overview of the Steps:

    • Consumption in Process
      - Create Business Process and use an Action
      - Release and Deploy the Process
      - Test the Process which is using the Action


Create BTP Destination

In the SAP BTP Cockpit, create a destination that will be used in the Action Editor to test the Action and in the Process execution.

ParameterValue
URLhttps://jsonplaceholder.typicode.com/
Additional Propertiessap.applicationdevelopment.actions.enabled = true
 sap.processautomation.enabled = true

 


Configure Destination for SAP Process Automation

To allow the usage of the BTP destination, you have to add the Destination in SAP Process Automation.

    • In the Settings or SAP Process Automation, select Destinations
    • Click New Destination
      select the Destination from the list and press Add
    • The destination is now added to the lst and can be used in SAP Process Automation


Create Action Project

In this sample we will create a simple Action Project for a REST API.
We will not change input/output parameters or customize the action.

Important: You need an Open API specification for your API to create Actions

    • For this example, just copy the definition from here to a local text file called ToDoAPI.json and save the file. We will use the file to create the Action Project with one Action.
      { "openapi": "3.0.0",
          "info": {
              "description": "This is a fake API of todo list",
              "title": "fake.todo",
              "version": "1.0.0"
          },
          "servers": [ { "url": "https://jsonplaceholder.typicode.com/" } ],
          "paths": {
              "/todos": {
                  "get": {
                      "summary": "get list of todos",
                      "description": "get list of todos",
                      "operationId": "get.todos",
                      "responses": {
                          "200": {
                              "description": "Successful response",
                              "content": { 
                                  "application/json": {
                                      "schema": {
         				        "type": "object",
      					"title": "Collection of Tasks",
      					"properties": {
      					        "responseArray": {
      							"type": "array",
      							"required": true,
      							"items": {
      								"properties": {
      									"userId": { "type": "number" },
      									"id": { "type": "number" },
      									"title": { "type": "string" },
      									"completed": { "type": "boolean" }
      } } } } } } } } } } } } }
    • In the Lobby of SAP Process Automation, create an Action Project.
    • Specify the name ToDo Actions and upload the API spec ToDoAPI.json, click Create
    • Select the actions from the list, click Add
    • Your Action Project will contain one action


Test an Action

You can test the execution of your action in the Action Editor. Lets test the Action 'get list of todos'.

    • Select 'get list of todos' from the list, the action has no input parameters
    • Select Tab Output, shows the fields returned when the action is executed

    • Select Tab Test, you can see the different options available to test an action.
      Connectivity Host allows you to test with an destination or Manual, you can enter the system details here.
    • Select the destination Demo, click Test
      The Response Preview will show the results


Release and Publish to Library

To be able to use the Action in a Process, we have to release and publish the Action Project.

    • Click Release

 

    • Provide release information, click Release
    • Click Publish to Library
    • On Publish Project, click Publish


Consumption in Process

Create Business Process and use an Action

 

    • From the Lobby select Create Process
    • Enter the Project Name, e.g. Demo Process and select Create
    • On the Create Process Dialog, enter the Process Name myActionProcess and select Create
      your canvas should look like here
    • Select the + to add a step to your process
    • Select Browse library, you will see all actions
      here I have used a filter to show only Actions from ToDo Actions project
    • Lets use 'get list of todos' action, click Add
    • As a last step we have to define a Destination variable
      This variable will be later used in the Execution to assign a destination created in BTP and configured in SAP Process Automation
    • Select Create Destination Variable, set system as Identifier and select Create
    • An Environment variable was created and your process should not display an error anymore
    • Now Save your process


Release and Deploy the Process

To test the action in the process, we will release and deploy the project.

    • clik Release
    • Enter a Version comment, click Release
    • click Deploy
    • On the Deploy a project dialog, select the Destination Demo, click Confirm
    • The Deploy button gets activated, click Deploy
    • Your project is deployed and the deployed version is shown

 

Test the Process which is using the Action

 

    • In the Monitor or SAP Process Automation, select Manage --> Process and Workflow Definitions
      you can use filter myActionProcess
    • select the myActionProcess from the list, click Start New Instance
    • On the Start New Instance you can specify input parameters, we have no input so we can use {}, click Start New Instance and Close
    • The instance will be started
    • Select Monitor -> Process and Workflow Instances
    • Reset the Filters to show all instances
    • in the Search, enter myActionProcess
    • Select myActionProcess from the list to show the instance results


Consumption in Automation

coming soon
...


Conclusion

Following this tutorial, you have seen all the steps to consume an Action in a process.

48 Comments