Sending Messages from ABAP, BTP Environment to Cloud integration (CPI) using Event Mesh
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.
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 J Pavan 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
or the SAP Help
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
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.
for more information on AMQP sender/receiver, check the below post:
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 🙂