This blog post showcase a small example of how to send events/messages from ABAP, BTP environment to SAP CPI using Event Mesh, all using the trial account. There can be many different scenarios that can use this example, for instance, if we have a side-by-side extension using ABAP, BTP environment, and to trigger a CPI flow for workflow or something else, we can use this approach.
Background
I recently gave a presentation in an SAP Community event about Event Mesh. For that, I took an example of sending messages from ABAP, BTP environment to CPI (Cloud Integration) using the Event mesh. BTW, I also took help from my friend
jpavan.kumar to do this :). ( It's more fun if you collaborate with someone and present than doing it alone, so give it a try once
🙂 ) So now I thought of writing about it as a simple blog post and here I am.
Creating the Event Mesh Instance:
For creating an event mesh instance(trial) with Queues & topics, follow the blog post (Appendix: 4) from
carlos.roggan
https://blogs.sap.com/2020/03/03/sap-cloud-application-programming-model-and-enterprise-messaging-1-...
or the SAP Help
https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/7e504322652d4791ade0ca2bbc5...
Create the service key for the instance, which we will use for communication with Event mesh, from ABAP & CPI.
Now create a Queue: queue1 and Topic (Queue Subscription) for that queue, topic1.
Preparing the ABAP, BTP environment:
in ABAP, BTP env., check the below blog post from
rich.heilman
https://blogs.sap.com/2021/05/06/how-to-leverage-the-sap-event-mesh-from-sap-btp-abap-environment/
https://github.com/SAP-samples/cloud-abap-event-mesh-api.git
Install it in ABAP cloud using the abapGit plugin,
then go to the class: zcl_ems_api and update the constants with the values from the service key(event mesh).
Now create a test class that inherits the interface: if_oo_adt_classrun and call the ems API class method: publish_message to topic as shown below:
In productive scenarios, we usually call this method from the save-sequence in the RAP service, to send the create/update/delete event data to the event mesh (e.g., in side-by-side extension).
Getting ready to receive the messages in CPI:
I will just create a dummy flow to receive the messages. The only important thing here is to configure the receiver correctly.
The receiver should be of type "AMQP". and in the connection tab, provide the details from the event mesh service key, (amqp segment)
along with that maintain the credentials as well.
After that configure the topic details in the processing tab.
that's it, our basic CPI flow is also done, you can enhance it with the further process as per the business.
f
or more information on AMQP sender/receiver, check the below post:
https://blogs.sap.com/2019/11/20/cloud-integration-connecting-to-external-messaging-systems-using-th...
Now when we execute the test ABAP program that was created in step1, we can see the CPI flow triggered in the message monitor.
(note: ignore the status: 'retry', it's a mistake from my side in the integration flow, too lazy to correct it
😞 )
That's the small example pavan and I showed at the community event. and of course, we use destinations to connect, instead of hardcoding all those information in the productive systems.
Share your thoughts or best practices or any added information in the comments
🙂
Cheers!
Mahesh