Skip to Content
Technical Articles
Author's profile photo Jigar Salecha

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.

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

  • Mta.yaml

  • 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

 

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Frank Li
      Frank Li

      That’s great, thank you for sharing. It seems that  event mesh service is not available for BTP Trial account.

      Author's profile photo Tobias Griebe
      Tobias Griebe

      Hi Frank Li,

      Event Mesh is available on the trial landscape as well. There it is called "dev" plan (instead of "default" plan). Please note that the feature scope is a little different for the two plans. But haveing a quick look at the blog post abov,e this scenario should also be possible with the "dev" plan. The above described process how to send a test event from the Event Mesh admin UI is not possible with the "dev" plan, for that I would use Postman or any other HTTP client to send an event to the Event Mesh REST interface.

      The service descriptor to create a "dev" instance is different from the "default" plan and also the way how to access the administration UI, but all this is covered in the tutorials: https://developers.sap.com/group.cp-enterprisemessaging-get-started.html

      Best regards,
      Tobias

      Author's profile photo Frank Li
      Frank Li

      Cannot%20find%20event%20mesh%20when%20try%20to%20create%20event%20instanceHi Tobias,

      Cannot find event mesh when try to create event instance

       

      The tutorials is really helpful. Follow try to creat instance of Event Mesh, but cannot find event mesh from drop down list as below. Do you know what’s the reason?

      Sub%20account%20info

      Sub account info

       

      Event%20mesh%20service%20subscription

      Event mesh service subscription

       

       

      Author's profile photo Tobias Griebe
      Tobias Griebe

      Hi Frank Li,

      from the screenshots I can see, that your trial account is on Azure in the Singapore region.

      The Event Mesh trial service is only availble in AWS Europe (Frankfurt) and AWS US East (VA): https://discovery-center.cloud.sap/serviceCatalog/event-mesh?region=all&tab=service_plan&licenseModel=free

      As far as I know you can just create a new subaccount in another region.

      Best regards,
      Tobias

      Author's profile photo Frank Li
      Frank Li

      Hi Tobias,

      Thank you for your help, now it works.

      Best regards,

      Frank

      Author's profile photo Fabiano Rosa
      Fabiano Rosa

      Great content Jigar, I'm glad to collaborated together in the Event Mesh topic.

      Regards,

      Fabiano Rosa

      Author's profile photo Jigar Salecha
      Jigar Salecha
      Blog Post Author

      Thank you Fabiano Rosa for your feedback !!

      I am glad too to have collaborated with you in the above Event Mesh space.

       

      Regards,

      Jigar Salecha

      Author's profile photo Rakesh Kumar
      Rakesh Kumar

      Hi Jigar,

      Thanks! for the detailed blog. It's helpful in my case as well where we are trying to trigger Workflow on BTP using S4Hana system. Have you uploaded the cap project in github? is it possible to refer it, if required?

      Please share the link if possible.

       

      Thanks,

      Rakesh

      Author's profile photo Saranya Sampath
      Saranya Sampath

      Hi ,

       

      I have created instance and service keys in my trial account. But my dashboard doesn't have Messaging client . Event-Mesh-%20DashboardEvent-Mesh- Dashboard

       

      Thanks in advance

      Saranya

      Author's profile photo Tobias Griebe
      Tobias Griebe

      Hi Saranya Sampath,

      that is correct. The Admin UI for the Trial accounts looks different from what you see when using the "default" plan.

      For the trial account it is not possible to have multiple messaging clients... there is only this single client.

      Best regards,
      Tobias

      Author's profile photo Vijayalaxmi Bishwal
      Vijayalaxmi Bishwal

      Hi Jigar,

      I have a similar requirement. Need to trigger Workflow based on the event from event mesh. Is it possible to share git hub link.

       

      Thanks,