Triggering SAP BTP Workflow using SAP Event Mesh

Hello Everyone,

In this blog post, you will learn to trigger a SAP BTP Workflow from a SAP Event Mesh Service using a nodejs app.

SAP Event Mesh is a fully managed cloud service that allows applications to communicate through asynchronous events. More details of SAP Event Mesh service can be found in the below link – https://discovery-center.cloud.sap/serviceCatalog/event-mesh?region=all

We can use this SAP Event Mesh service to trigger a BTP workflow using an intermediate node-js app.

So how can we achieve this?

I would take you to a step-by-step process to achieve the objective –

a) Create Instance of SAP Event Mesh in SAP BTP by following tutorial –https://developers.sap.com/tutorials/cp-enterprisemessaging-instance-create.html

I created the below instance of SAP Event Mesh in my BTP account –

b) Create Queues and Topics in SAP Event Mesh Dashboard by following tutorial – https://developers.sap.com/tutorials/cp-enterprisemessaging-queue-queuesubscription.html

I created below queue and topics in my SAP Event Dashboard –

c) Create a CAP project with a nodejs srv in SAP BAS. Github link for the project – https://github.com/jigchin/btpmesh

Some important changes in the CAP project files are listed below –

  • Package.json –

  • Cat-service.js –

  • WorkflowApi.js –

d) Create a workflow destination in the nxtgen-mesh-wf-poc-dest service instance as shown below

The above-required information can be collected from the workflow service instance key as shown below –

e) Build the CAP project and deploy it in a cloud foundry space.

f) For testing the Event Mesh node service we can use the test capability available on the SAP Event Mesh Dashboard to publish messages to a particular topic –

Topic – refapps/bpems/abc/ce/sap/s4/beh/businesspartner/v1/BusinessPartner/Changed/v1

Content-Type – application/cloudevents+json; charset=utf-8

Message – {“type”:”sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1″,”specversion”:”1.0″,”source”:”/default/sap.s4.beh/S4HCLNT110″,”id”:”000d3a28-9c73-1eec-928b-79fdfb9c4910″,”time”:”2021-11-19T10:39:31Z”,”datacontenttype”:”application/json”,”data”:{“BusinessPartner”:”101″}}

g) Once the message is published in the test client, now we can go to s4hana-em-poc-app-srv application and check the logs to see if the logs are generated for the published message.

h) Finally open the flp portal and check if the workflow is triggered with the context in the Monitor Workflow app –

So finally, now you can see that the workflow gets triggered whenever an event is published on SAP Event Mesh.

Hopefully, this will help if you are embarking on the journey of publishing events from S/4 HANA to SAP Cloud Workflow. Happy learning!

Share your thoughts or any doubts/questions in the comments 🙂

Also kindly note you can find Q&A and post questions in the SAP Event Mesh community for any queries  – https://answers.sap.com/tags/73554900100800000765

Cheers!

Jigar Salecha