Technical Articles
SAP Process Automation – Your first simple Action Project: End to End
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:
- Create BTP Destination
- Configure Destination for SAP Process Automation
- Create Action Project
- Test an Action
- Release and Publish to Library
- Consumption in Process
– Create Business Process and use an Action
– Release and Deploy the Process
– Test the Process which is using the Action - Consumption in Automation
– coming soon
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.
Parameter | Value |
URL | https://jsonplaceholder.typicode.com/ |
Additional Properties | sap.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.
Does this require an running Agent or is the caller SPA itself?
Testing Actions in the Action Editor or execution within a process does not require an running Agent.
Execution within in automation requires an running Agent.
Really informative article Thomas Jentsch
Is it safe to say that Action Project is used to call APIs only?
If that is the case then isn't there an option to call APIs from activities in Automation?
Yes, Action Project is used currently for REST APIs.
And yes, you can use this also in automations.
you need to add the Action Project as a dependency to your SPA project and after that step you can use the actions in your automations.
(using an action in processes, the dependency is added automatically for automations this is a manual step)
Will add the consumption in automations to this blog asap.
Hi Thomas,
I followed your guide but I do not get automatically output fields.
What am I doing wrong?
Thanks.
Just tested on my trial and works fine. Seems to be an issue in the ToDoAPI.json, can you please check the file and may be create just a new one.
Hi Thomas,
I've checked the file, and try it again, with the same result: no output fields.
Also when I am trying the blog of Archana Shukla (business partner api - json) (https://blogs.sap.com/2022/10/21/connect-to-external-systems-using-actions-in-sap-process-automation/) I get also no input and output fields.
Has this something to do with our BTP account. I am not using a trial account but a full BTP account.
Thanks.
Kr,
Bram
Hello Thomas Jentsch ,
thank you for very nice morning blogpost. It is always very pleasant to start a day with such small and interesting article which will push your knowledge a little bit further.
But... Everything went fine until I tried to test call the api. I am receiving the error - see below.
I also tried to add dummy parameter to query and path, tried to do test with manual url instead of destination, but with same result.
Maybe it is some temporary problem on SAP side?
Error on test
Also, the lobby and UI of BUILD (SPA) has changed due to recent TechED, but most of screenshots are up to date.
Good work - thanks
Vlado
Could reproduce the issue, should be fixed very soon.
HI Thomas,
I am also facing the same issue when try this blog,
when can I expect the fix for the issue?
Thanks,
Venkata Sai
Tested and it is fixed.
Thanks Thomas Jentsch for this excellent blog. Awesome and comprehensive summary!
Updated the openAPI spec, so the action can be used in another tutorial I'm currently working on.
(the output parameter must be defined as required)
Hi Thomas Jentsch
Thanks for the blog.
I've a question regarding an error I am getting. I've created an Action Project to expose an API from my service. The API works fine from the Action Editor. I've then published it and used in a Process Automation project.
I want this action to be called after task is approved. I can see that after approval, the API is called but it returns the below error:
I've checked the destination and it seems fine. Testing from Action Editor using the same destination works fine.
Any idea what could be the issue? Am I missing any configuration?
Thanks
This is a limitation for this destination type we have in process execution today, as there is no user context (which is available in Action Editor and Forms). This will change when user principal propagation for Processes will be released (current plan is to have this in Februrary).
Thanks for the reply Thomas Jentsch
Any link or channel where I can track the releases?
Hi Thomas Jentsch
I have a question related to Action Project.
After creating an action project, few of the APIs have changed. Therefore I want to update the API Specification but I can't find any option to do so. There is no way to reupload the Open API spec
Is that a limitation or am I missing anything?
Thanks
Girish
You have to import the modified OpenAPI spec (JSON) again to your project.
Please be aware, that this will overwrite your manual modifications in the Action project with the definition from the spec.
I got the option. I wonder why I couldn't locate it earlier 😀
Thanks for your help!
Hi Thomas Jentsch ,
Very helpful blog , just FYI i have used the https://convert.odata-openapi.net/ for the converter from ODATA to Open API and was able to consume on-premise API .
Thanks,
Vijaya
Hi Vijay,
great, thank you for the information and the feedback.
regards
Thomas
Also for CAP based applications, following command works well for generating the Open API spec:
Hi Thomas Jentsch
Thanks for the blog.
I've a question regarding an error I am getting. I've created an Action Project to expose an API from my service. The API works fine from the Action Editor. I've then published it and used in a Process Automation project.
result:
{
"data": [
{
"upsideQuantity": "100.000",
"commitUOM": "EA",
"commitEndDate": "2023-01-28",
"type": "orderForecast",
"forecastQuantity": "1000.000"
}]}
The action executed successfully but it's not giving me the any output data.
result:
{
"action_get_getLastUpdatedTime_2": {
"result": {}
}
}
Can you please help me here??
Thanks,
Rajasekhar
Can you please check if your action has an output schema for the successful response code.
In the attached screenshot you can see the response body from the requested.
Sometimes this is missing in openAPI specs and must be manually updated to get results not only when testing the action, but also when the action is used in a process/automation.
Hi Thomas Jentsch ,
In action project we are getting the output PFB,
But while consuming in the process it is not giving any data in the context.
Can you please help with the issue.
Thanks,
Rajasekhar
How does the definition in the Output Tab of the action look like ?
If the Body is empty, that's the issue.