Supply Chain Management Blogs by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
1,296
In this blog I would like to show how to integrate with SAP Cloud Platform Workflow and SAP Business Workflow from SAP Leonardo IoT actions.

Integrating SAP Leonardo IoT to already powerful SAP’s workflow framework brings valuable insights into IoT sensor data to further enrich business context.

Workflows can be triggered in a similar way as for any other service integration in SAP Leonardo IoT actions by creating destination through SAP Cloud Platform Destination service and providing a valid payload.

 

Integration with SAP Cloud Platform Workflow

Before proceeding with SAP Cloud Platform Workflow integration, it is prerequisite to create and configure a service instance of SAP Cloud Platform Workflow service.

For more details on SAP Cloud Platform Workflow, please follow SAP help link or  SAP tutorial.

 

SAP Cloud Platform Workflow Definition

To illustrate SAP Cloud Platform Workflow integration with SAP Leonardo IoT actions in this blog, I will use a user task defined workflow with “Approve” and “Reject” decision support with context variable “Thing” as an example.





 

SAP Cloud Platform Destination

Create a destination in SAP Cloud Platform.  Following is a reference destination:



 

Note:

Destination URL: If your region is eu10, the URL should look the following way:

https://api.workflow-sap.cfapps.eu10.hana.ondemand.com/workflow-service/rest/v1/workflow-instances

Token service URL: If your region is eu10 and subdomain is sap, the URL should look the following way:

https://sap.authentication.eu10.hana.ondemand.com/oauth/token

 

SAP Leonardo IoT Action

Create a new action in SAP Leonardo IoT by going to Action tile and clicking on “New” button:



 

Choose the destination created for SAP Cloud Platform Workflow Integration from “Destination” drop down box and relevant payload in “Request body”.  Sample payload depicted below contains “definitionId” which is workflow ID and “context” variable “Thing” as noted from step above:



Note:

Tokens can be used as values of context variables.  In this example, token “${thing.name}” is used for “Thing” context variable.  During execution of action token will be replaced with actual value.

 

Result

When SAP Leonardo IoT action executes based on rule condition defined, it will invoke SAP Cloud Platform Workflow API to automatically start workflow instance.  In this blog’s example, an instance of “Approve” or “Reject” user task workflow will start with token ${thing.name} replaced with the thing name (JM-T-807):



 

Integration with SAP Business Workflow

For workflow integration with on-premise SAP S/4 HANA system, one of the prerequisites is to setup SAP Cloud Connector in the Cloud Foundry sub account to open a HTTP/S tunnel to the S/4 HANA system.

More information on Cloud Connector can be found in this help link.

In addition, valid SAP Business Workflow must be created via SAP Workflow Builder (Transaction: SWDS).

Detailed information on how to create a backend workflow can be found in this help link.

 

SAP Business Workflow Definition

To illustrate SAP Business Workflow integration with SAP Leonardo IoT actions in this blog, a backend workflow with one “Send Email” step will be used.  When this workflow is triggered an email will be sent out to the email recipient specified in step definition:





 

SAP Cloud Platform Destination

As mentioned earlier, Cloud Connector is mandatory to connect to on-premise SAP S/4 HANA system.

Therefore, when creating a destination “Proxy Type” will be “OnPremise” and location ID of Cloud Connector must be provided:



 

Note:

Destination URL should be following format:

http://<HOST NAME>:<PORT>/SAP/BC/WORKFLOW_XML/?~protocol=01&~localkey=<WORKFLOW ID>&sap-client=<CLIENT NUMBER>

 

SAP Leonardo IoT Action

Choose the destination created for SAP Business Workflow Integration from “Destination” drop down box and relevant payload in “Request body”:



 

Format of workflow payload:



 

Result

When SAP Leonardo IoT action executes based on rule condition defined, it will invoke SAP Business Workflow API to automatically create workflow process instance.  In this blog’s example, an email will be sent out to the recipient specified in email workflow step:



 

Summary

As outlined in this blog, SAP Leonardo IoT provides out of the box integration to both SAP Cloud Platform Workflow and SAP Business Workflow.

While a rule in SAP Leonardo IoT will bring business context to IoT sensor data, SAP Leonardo actions can integrate to either workflow seamlessly to trigger actionable steps.

Further details on how to create destinations in SAP Cloud Platform and types supported by SAP Leonardo IoT actions can be found in my previous blog.