Technical Articles
Orchestrating Robotic Process Automation with SAP Workflow Service
The pursuit of Efficiency improvement is one of main objectives for a modern company since the invention of Scientific Management by Frederick Winslow Taylor, especially on the labor productivity increase through analysis and synthesis of workflow, standardization of best practices etc during the second industrialization era, also well known as Taylorism. A scene of Production Automation with machinery in factory is well illustrated in movie Modern Times starred by Charlie Chaplin.
With the development of modern Scientific Management after World War II, and the invention of modern computer, computer-based management software becomes the “central nerve system” of a business, centrally planing the business activities, execution monitoring, managing and coordinating all the resources within and even beyond the company, which has taken the practices of scientific management for efficiency yield to the next level.
The customers, suppliers, employees, materials/products etc of a company in real-world are reflected as some system records of master data, and the interaction and exchange between customer, supplier, and other parties are mapped as the transactional records of system. A set of related activities or tasks are grouped and structured to form a business process, such as Order-to-Cash process. Its information flow is made up of
- Data entry of system record representing the states of the process, such as a record of sales quote has been entered into system by the sales representative or sales assistant, which indicates the early state of order-to-cash process where customer seems interested on the company’s product or service, and request for a quote, now the sale representative has responded with a sales quote to the customer.
- User tasks recording human intervention in the process, such as an exception of price condition in the sales quote triggers an approval request to sales manager, where sales manager needs to make a decision to approve or not.
- Notification of state change about the process to human agent for communication and collaboration, such as the sales representative receives an internal system message once the sales quote is approved, and whist, the sales quote is automatically emailed to the customer.
Any manual activity in a sequential process will potentially slow down the whole process, any error by human may lead to economic loss or efficiency deficit.
Therefore, Process Automation is key to improve operation efficiency by reducing the repetitive manual processes, and eliminating the human error. Especially, with the recent years’ technological advance on AI/ML, IoT etc intelligent technologies. Robotic Process Automation is fueled with intelligence, where we have SAP Intelligent Robotic Process Automation to create, schedule, manage, and monitor intelligent bots for business process automation.
On the other hand, Process Orchestration is crucial to achieve business agility, process flexibility and process visibility by connecting and orchestrating business activities, user tasks and communication/collaboration, where SAP Workflow comes into place.
Phew, what a lengthy opening! I am not here to discuss scientific management, but to share my exploration of SAP Workflow Service and SAP Intelligent RPA, seeing how we can put together process orchestration and process automation to achieve business agility and operation efficiency in one shot. In addition, the scenarios of synergy & integration between SAP Workflow Service and SAP Intelligent RPA have been well explained in the blog post about The synergy & integration between SAP Intelligent BPM and SAP Intelligent RPA by Seshadri Sreenivas Ramanarayanan, which is really an informative and worthy read.
The objective of this blog post is not to discuss the design of an SAP Intelligent RPA Bot. Instead, it aims to show how easy to implement a predefined bot by SAP, and how you can extend it with SAP Workflow.
Sample Scenario – Automation of Mass Maintenance of Sales Prices in SAP S4/HANA or SAP S4/HANA Cloud
Let’s start the story with John, a sales assistant of Amika, one of John’s responsibility is to maintain the sales prices of the products in their ERP system SAP S4/HANA Cloud. Hundreds of sales price are manually entered into the system by John, which usually take John a few days, and it is error-prone in such a repetitive manual task. The company have recently implemented SAP Intelligent RPA to automate their manual process. Fortunately, Mass Maintenance of Sales Price is available as the a predefined scenario SAP Intelligent Robotic Process Store, which the partner can help to implement it and go live easily by following its configuration guide.
Here you have the video how to configure the mass maintenance of sales prices bot for SAP S4/HANA Cloud.
Now with in place of SAP Intelligent RPA, what john needs to do is to prepare the Sales Prices in the predefined excel template, then he can trigger the process automation in attended mode or with a schedule job in unattended mode. As a result, the entire process of sales prices maintenance is significantly reduced with process automation.
Here you can see how John can run the bot to automate the process of creating and updating the price conditions.
However, the sales manager Janet would like to have some visibility of the the process, which the sales prices list should be reviewed and approved in prior to data entry with the automation, assuring the sales prices are correctly maintained.
As a partner, you could have two options to achieve so by orchestrating the process automation by SAP Intelligent RPA Bots with SAP Workflow
- Option 1: (Covered in this blog post)How to enhance a predefined SAP Intelligent RPA bot about mass maintenance of sales prices in SAP S4/HANA Cloud by adding an approval request for reviewing and approving the changes of sales prices condition in prior of the automation. Exactly the same approach as Scenario 2: Trigger the SAP Intelligent RPA bot from SAP Cloud Platform Workflow in Seshadri’s blog post mentioned above.
- Option 2: (Covered in a separated blog post) How to achieve the same scenario with the built-in process orchestration capability of the SAP Intelligent RPA 2.0 Cloud Studio with automation, user task, and process.
Option 1: Orchestrating the SAP Intelligent RPA Bots explicitly with SAP Workflow Service through API trigger
Given a SAP Intelligent RPA Bot could be triggered through API, and SAP Workflow Service can fire an http request with a Service Task, therefore, we can explicitly invoke and orchestrate an SAP Intelligent RPA bot with a Service Task in SAP Workflow Service. You may refer to Seshadri’s blog post for a detailed explanation.
Prerequisites:
- You have gone through this Tutorial to Get Started with SAP Workflow Service
- An API trigger to the Bot has been added for the package Mass Maintenance of Sales Prices in an Environment.
Basis of extending and orchestrating an SAP Intelligent RPA Bot with SAP Workflow Service.
Here you have video to explain the detail about how to extend an SAP Intelligent RPA Bot with SAP Workflow Service by adding email notification, user task for approval and service task to trigger the bot through API.
The overall workflow design of sales_price_workflow as
An sample of a workflow instance of workflow sales_prices_workflow through REST API, which you can refer to api.sap.com for more detail.
{
"definitionId": "sales_prices_workflow",
"context": {
"salesPrices": {
"requestBy": "yatsea@sap.com",
"requestAt": "2021-03-23T03:10:57.523Z",
"approveBy": "yatsea@sap.com",
"approvalStatus": "New",
"excelBaseFolder": "C:\\temp\\MaintainSalesPrices\\Excel",
"remarks": "Special prices for Account 10100001",
"approvalRemarks": ""
}
}
}
The custom attributes of the workflow, which are used to store the additional information about the approval.
- approvalStatus: ${context.salesPrices.approvalStatus}
- appvovalRemarks: ${context.salesPrices.approvalRemarks}
Now, let’s have a close look at the workflow design step by step.
Step 1: New Approval Email Notification to the approver
This is an mail task to notify the approver for new approval request.
Please refer to this online help about Configure the Workflow Service Mail Destination
The configurations of the new approval email notification
To: ${context.salesPrices.approveBy}
Subject: Approval required for Mass Maintenance of Sales Price by SAP Intelligent RPA
Plain Text Body:
Dear ${context.salesPrices.approveBy},
There is a new request pending for your approval.
Request By: ${context.salesPrices.requestBy}
Request At: ${context.salesPrices.requestAt}
Sales Prices Excel Base Folder: ${context.salesPrices.excelBaseFolder}
Request Remarks: ${context.salesPrices.remarks}
Please review and take action via My Inbox of SAP Workflow Service.
https://******.cockpit.workflowmanagement.cfapps.eu10.hana.ondemand.com/cp.portal/site#WorkflowTask-DisplayMyInbox?sap-ui-app-id-hint=cross.fnd.fiori.inbox&substitution=true&userSearch=false
This is an auto-generated email notification. Please DO NOT reply.
Kind Regards,
SAP Workflow Service
A sample of email notification
Step 2: Approval user task for Mass Maintenance of Sales Prices via SAP Intelligent RPA Bot
Properties
- ID: usertask1
- Name: Approval for Mass Maintenance of Sales Prices via SAP Intelligent RPA
- Subject: Approval for Sales Prices
- Recipient User: ${context.salesPrices.approveBy}
The design of approval form
Fields:
Decisions:
In runtime, the approval form of this user task look like this.
Step 3- Exclusive Gateway about Approve or Reject.
The following Exclusive Gateway about Approve or Reject
- Approve as the default routine in the following Exclusive Gateway.
- Reject routine with condition as
${usertasks.usertask1.last.decision=="reject"}
Step 4-(Approve routine) Prepare the payload to trigger SAP Intelligent RPA bot with api with a script task.
var rpaApiTrigger = {
request: {
"invocationContext": "${invocation_context}",
"input": {}
}
};
$.context.rpaApiTrigger = rpaApiTrigger;
Step 5-(Approve routine) Trigger the SAP Intelligent RPA bot via api with a service task
Service Task Properties
Destination irpa_api_trigger is defined in your SAP BTP, Cloud Foundry Environment for api trigger of SAP Intelligent RPA Bot. For example, as showed in the prerequisite section, I have an api trigger to my bot via url as https://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggers/d629028f-ef7f-4875-8198-207b1c564dd1/runs.
- URL: In my sample, the url is configure as
https://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggersSince the full api trigger url of my bots has a format ofhttps://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggers/<YOUR_BOT_TRIGGER_ID>/runs
Therefore we can configure the url of destination irpa_api_trigger with the common part, such as https://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggers, the rest /<YOUR_BOT_TRIGGER_ID>/runs will be set up in the path of service task in workflow as screen shot of Service Task Properties above as /d629028f-ef7f-4875-8198-207b1c564dd1/runs. During the run-time, the service task will compose the full url to trigger by combining the url in destination and path in service task for the http request.
- Authentication: OAuth2ClientCredentials. Please refer to this online help for details of OAuth2ClientCredentials
- Client ID: The client id from the service key of your SAP Intelligent RPA tenant
- Client Secret: The client secret from the service key of your SAP Intelligent RPA tenant
- Token Service URL: The authentication url to request access OAuth2.0 token from from the service key of your SAP Intelligent RPA tenant. Please refer to this online help about details. For example, the service key of my SAP Intelligent RPA tenant like this.
{ "uri": "https://tenant-url... .com", "uaa": { "uaadomain": "authentication.sap.hana.ondemand.com", "tenantmode": "shared", "sburl": "https://uaa-domain... .com", "clientid": "abcdef!a12345|xyz!a1234", "verificationkey": "-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----", "apiurl": "https://api.authentication-domain... .com", "xsappname": "abcdef!a12345|xyz!b1234", "identityzone": "identity-zone-name", "identityzoneid": "identity-zone-id", "clientsecret": "xxxxxxxxxxx=", "tenantid": "tenant-id", "url": "https://******trial.authentication.eu10.hana.ondemand.com/" <<---- this is the url property } }
The url https://******trial.authentication.eu10.hana.ondemand.com is the domain of oauth 2.0 authentication to my SAP Intelligent RPA Tenant.
And then just add /oauth/token to the domain as the Token Service URL.
In this case, the Token Service URL of my SAP Intelligent RPA Tenant is
https://******trial.authentication.eu10.hana.ondemand.com/oauth/token
Step 6: Prepare the result email
Prepare the result email with a script task
var approveTask = $.usertasks.usertask1.last;
var resultEmail = {};
var decision = 'Approved';
if(approveTask.decision === 'reject')
{
decision = 'Rejected';
}
$.context.salesPrices.approvalStatus = decision;
resultEmail.subject = 'Request ' + decision + ' for Mass Maintenace of Sales Prices ' + $.context.salesPrices.excelBaseFolder;
resultEmail.body =
'Dear '+ $.context.salesPrices.requestBy +
',\n\nYour request about mass maintenance of sales prices has been '+ decision + ' by ' + $.context.salesPrices.approveBy
+'\n\nPrice Excel Path: '+$.context.salesPrices.excelBaseFolder
+'\nRequested At: ' + $.context.salesPrices.requestAt
+'\nRemarks: ' + $.context.salesPrices.remarks
+"\nApprover's remarks: " + $.context.salesPrices.approvalRemarks
+'\n\nThis is a auto-generated email notification by SAP Worflow Service. Please DO NOT reply.'
+'\n\nKind Regards,'
+'\nSAP Workflow Service';
$.context.resultEmail = resultEmail;
Step 7: Result email notification with a mail task
A sample of result email in run-time
Summary
As you can see, we can easily enhance a process automation of SAP Intelligent RPA Bot with SAP Workflow Service by adding email notification for communication with mail task, user task such as approval, and triggering the SAP Intelligent RPA Bot via API trigger with service task. As a result, we can achieve Process Automation for Operation Efficiency and Process Flexibility for Business Agility at the same time.
In the next blog post, we’ll do the same scenario with built-in Process Orchestration capability of SAP Intelligent RPA Cloud Studio, which has the build block of automation, user task and process.
I also tried to connect irpa and SCPWF.
I'm having trouble with the following error message
Please help!
My concern is that in "Step 5-(Approve routine) Trigger the SAP Intelligent RPA bot via api with a service task", I didn't understand the Token Service URL, and I put the third URL from the top of the IRPA service key.
Thank you very much for your help.
Hi Kimitoshi,
The token service url is the URL to get the access token of the api trigger for the SAP Intelligent RPA Bot, which is taken from the service key of your SAP iRPA tenant, here you have the online help about the detail.
For example, the sample service key of my SAP iRPA tenant is like
the url property above https://******trial.authentication.eu10.hana.ondemand.com/ is used to get the access token to sap irpa service via REST api.
However, the completed token service url should be https://******trial.authentication.eu10.hana.ondemand.com/oauth/token
Please don't forget to add /oauth/token to the url.
Kind Regards, Yatsea
Hi Yatsea
thank you
I tried to use the URL as you said, but I still get the following error.
Error message:The authentication type 'OAuth2ClientCredentials' is not supported. For supported authentication types, see the Destinations section in the SAP Workflow service documentation.
help me
Hi Kimitoshi,
Please kindly check this blog post about API Triggers & Notifiers in SAP Intelligent RPA. After reading this blog post, you should be able to trigger the bot via postman.
And please check the list below:
1.Have you created a service key for your SAP Intelligent RPA service instance as this online help?
2.Have you added an API trigger to the bot?
3.Are you able to trigger the bot via postman as per instruction of the online help and blog post above?
4.Can you please share the screenshot of your destination configuration for irpa_api_trigger as mentioned in step 5?
Kind Regards, Yatsea
hi yatsea
thankyou
API integration with postman is successful.
but The path to details may be unclear
Hi Kimitosh,
Thanks for the feedback. Let me explain with an example.
For example, here is my url to trigger the bot.
https://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggers/d629028f-ef7f-4875-8198-207b1c511111/runs
The URL in irpa_api_trigger destination is https://api.irpa-trial.cfapps.eu10.hana.ondemand.com/runtime/v1/apiTriggers
Then the path in in the service task to invoke the bot is /d629028f-ef7f-4875-8198-207b1c511111/runs
In run time, the workflow will combine the url of the destination and the path in the service task as a completed url. In this way, the irpa_api_trigger destination could be used for all of my bots, and the path(e.g /d629028f-ef7f-4875-8198-207b1c511111/runs) could be dynamic configured in the service task per bot.
Kind Regards, Yatsea
hi yatsea
very very thankyou
I see.
Thank you very much for your kind help in setting up the API.
However, even after changing the path, I still get the same error.
I checked the destination connection and got a 403, is this okay?
Is there any other reason for the error?
Please let me know if there is any other reason for the error.
Hi Kimitoshi,
My check connection return "Connection to "irpa_api_trigger" established. Response returned: "401:Unauthorized"". This is an reasonable error for it requires authentication with token service url to get the access token.
However, error 403 indicate access forbidden.
It is mentioned in your last reply that API trigger to bot is successful via postman, then it should also work in workflow, as no difference to api trigger from workflow and postman.
Please assure the Token Service URL, Client ID and Client Secret are correctly setup in the destination, just compare them with your postman.
Your Token Service URL(https://sandbox1.authentication....) seems weird to me.
My trial account is in eu10(AWS, Frankfurt), my token service url is
https://ffe*****trial.authentication.eu10.hana.ondemand.com/oauth/token
ffe*****trial as my btp trial account.
Kind Regards, Yatsea
hi yatsea
thanks
but My Token Service URL is using the Access Token URL in postman
Hi Kimitoshi,
Since your api trigger to bot works fine with postman, then the problem resides in the destination of SAP BTP in JP10 region.
Error message:The authentication type 'OAuth2ClientCredentials' is not supported. For supported authentication types, see the Destinations section in the SAP Workflow service documentation.
There seem some differences of Workflow Service between the SAP BTP JP10 and EU10.
OAuth2ClientCredentials is supported in the Workflow Service of region EU10(AWS, Frankfurt), but seems not supported in the the Workflow Service of region JP10.
Could you please report an incident to SAP BTP support team if possible?
or contact your BTP contact in Japan if any
or post a question on the SCN with reference of our conversation here, hopefully you can find it out there.
Thanks.
Kind Regards, Yatsea
hi yatsea
I see.
I will try to register an incident.
Thank you very much for your help.
Excuse me for the additional question.
Where did you get this information from?
>OAuth2ClientCredentials is supported in the Workflow Service of region EU10(AWS, Frankfurt),
>but seems not supported in the the Workflow Service of region JP10.
Hi Kimitoshi,
In my trial account located in EU10, my workflow can trigger the SAP Intelligent bot through service task as my video.
>but seems not supported in the the Workflow Service of region JP10.
This is my feeling and reasoning based on our conversation, you can trigger the bot with postman, but encounter an error message in your test with workflow as "Error message:The authentication type 'OAuth2ClientCredentials' is not supported." even after we have checked all the configuration in the destination and workflow. That is why I ask you to confirm it with SAP BTP support.
Kind Regards, Yatsea