Technical Articles
SAP Event Mesh – Making S/4HANA Event Notification Easy
Disclaimer :
SAP Cloud Platform Enterprise Messaging has been given a name and is now known as SAP Event Mesh. Do follow this blog by Martin Bachmann to get complete details. Following this concept, this blog has been changed to include SAP Event Mesh. However, the images will still have the SAP Enterprise Messaging names.
With Getting Started with SAP Event Mesh you would have got a feel of SAP Event Mesh. One of the features, that makes SAP Event Mesh completely different than any other Message Broker in the market, is its ability to enable event-driven applications.
An Event can be defined as a significant change in state.
Event-Driven architecture, a software architecture pattern that promotes the production, detection, consumption of and reaction to events.
Monolithic applications have challenges like scalability, reliability and availability and agility. And most probably the root cause of such challenge is high cohesiveness and high coupling of its components. With Micro-services, flexibility comes with the capability of scaling only the needed components and not the application as a whole. Micro-services with Event-Driven Architecture to a great extend solves these challenges and allows building applications capable of dynamic and ever-changing capabilities because of the loosely-coupled architectures where the micro-services are designed to notify each other of changes using events.
And to be able to build such an Intelligent Enterprise, SAP Event Mesh is supposed to play a major role by helping the event notification between micro-services or two different heterogeneous systems.
SAP Event Mesh does support Event-Driven programming model. It has the capability to
- Propagate/Distribute Events across distributed landscapes across cloud and on-premise
- Out-of-box event enablement framework for S/4HANA and SFSF standard business objects
- Open standards and protocols-based communication
- Support for SAP Business Technology Platform events
Building on this thought process, SAP Event Bus has a feature of out-of-box event enablement from S/4HANA or SFSF business objects.
This blog is dedicated to help the developers build an application which requires event handling from S/4HANA.
To be able to consume events from an Event Source, a developer needs to follow the following steps. 1. Create SAP Event Mesh Instance (including OAuth2.0 Client ID and Secret) to be used by Eventing 2. Create S/4 Communication System and Communication Arrangement 3. Maintain Event Topics for a Channel 4. Queue Subscription to the Event Topic Pattern |
Assumption:
- You already have an SAP Event Mesh instance configured in your CF account. Follow Getting Started with SAP Event Mesh , if you are yet to.
- SAP Cloud Connector (if needed) and Destination configuration to access S/4HANA event catalog from CF is already completed.
Once we have the SAP Event Mesh Instance available, we need to complete following configurations to enable out-of-box Eventing support from S/4HANA using SAP Event Mesh.
Make the SAP Event Mesh Instance ready for Eventing |
Step 1:
Select the newly created SAP Event Mesh instance,
Step 2:
- Select the Service Key.
- Click on Create Service Key.
Step 3:
- Provide any name.
- Make a note of the client ID, client secret, token endpoint and base URL, then use these parameters to create a communication arrangement.
- Save
Step 4:
The newly created Service Key contains following information:
- clientId: This ID is used to log on to the SAP Event Mesh endpoint from outside
- clientsecret: This is the password to be used with the clientId.
- uri: These are the endpoints provided by SAP Event Mesh. From this
we can get the hostname and path needed for the configuration of the
Communication Arrangement on the S/4 system.
Note: SAP Event Mesh provides several endpoints supporting different protocols (e.g. AMQP1.0 and MQTT 3.1.1 over WebSocket and REST).
Dear Readers,
With the S/4HANA 2008 release, the configuration which needs to be done has changed. Hence, instead of following the S/4HANA configuration as mentioned below, please follow this blog to perform the required configuration. However, do not hesitate to post your queries in this blog. I will continue responding.
Configuring Communication System and Communication arrangement on S/4HANA system |
Step 5:
Logon to S/4 System with an Administrator user:
Navigate to Communication Management area.
Step 6:
General overview of the necessary steps described in this guide:
- Create Communication System (like defining a RFC destination)
- Create Communication User to access the S/4 system from the outside – this will be done during creation of communication system
- Create Communication Arrangement
Step 7:
Select the Communication Systems tile and click on New.
Provide any unique System ID and System Name and click Create.
Step 8:
The newly created Communication System is being displayed. Scroll down to the Technical Data section and provide the General configuration settings:
- Host Name is on…FACTORY/TRIAL: enterprise-messaging-messaging-gateway.cfapps.eu10.hana.ondemand.com
Or you can find the information from the Service Instance: Eventing – Service Keys (without https:// part)
Under OAuth 2.0 Settings provide:
- tokenendpoint replacing the last path segments with /oauth/authorize
- tokenendpoint as in the Service Key information ending with /oauth/token
Step 9:
In the section User for Inbound Communication click the Add button.
The Inbound Communication user is needed to access the S/4 system from the outside.
Step 10:
If you already have an Inbound Communication User available, you can re-use the same.
Otherwise create a new user by clicking on New User.
Step 11:
- Provide a unique User Name and a Description
- Either provide a password or click on Propose Password
- Save the proposed password to a save place, there is no other way to retrieve this password
- Complete the user creation by clicking on Create
- The user and password are needed when retrieving the Event Catalogs from the S/4 system
Step 12:
The newly created Inbound Communication User is automatically selected in the dialog.
Click OK to assign this user.
Step 13:
In the section User for Outbound Communication click the Add button.
The Outbound Communication User is required to connect from the S/4 system to the SAP Event Mesh on CF. The required credentials have been generated when creating the Service Key on CF.
Step 14:
- Authentication Method select OAuth 2.0
- OAuth 2.0 Client ID from Service Instance: Eventing – Service Keys
- Client Secret from Service Instance: Eventing – Service Keys
- Create the New Outbound User
- Finally Save the Communication System
Step 15:
Let us set up the Communication Arrangement.
In Home screen select the Communications Arrangements tile
to create a new Communication Arrangement. Click the New button and provide the following data:
- Scenario: select SAP_COM_0092 from the value help
- Provide any unique Arrangement Name
- Click Create
Step 16:
Under Common Data select previously created Communication System from the value help → Inbound Communication, Inbound Services and Outbound Services get filled automatically.
Step 17:
Fill in the Additional Properties:
- Give any name for the Channel
- Give any Description for the Channel
- Topic Space: best practice is to use system name, to see where events are coming from. The Topic pattern of event payload will be sent to SAP Event Mesh service instance as
<topic space>/<event path>
- QoS (Quality of Service) = 1 (At least once)
- Reconnect Attempts: any amount of reconnect attempts in case of a connection error
- Reconnect Wait Time: idle time between 2 reconnection tries
Step 18:
Finally, the details for the Outbound Services need to be provided:
As Path provide: /protocols/mqtt311ws
Click Check Connection
Save the Communication Arrangement.
The Check Connection will try to check if a connection(by creating web-socket) can be established between S/4 and SAP Business Technology Platform.
Step 19:
In the Inbound Services section you can find the URL to call the Event Browser Service.
Maintain Event Topics for a Channel |
Step 20:
Logon to S/4 Backend system with a user that has access to
Implementation Cockpit → Manage Your Solution
Click on Manage Your Solution
Step 21:
- In the filter provide messaging
- from the results list select the entry called Event Handling
Step 22:
Click on Configure for the entry called Maintain Event Topics
Step 23:
Click the value help to choose your Event Channel from the list of
available channels.
Confirm your selection by clicking the green check mark.
Step 24:
- Select New Entries
- Select the first empty line of the table and use the value help to
open the list of available Topics. - Select any of the Topics you want to add to your Channel.
You can choose between specific Topics only or by selecting sub paths. - Click on Save
- Click on Exit
Setup Queue Subscription to consume Event Topics to be exposed by this channel. |
Step 25:
- Open the SAP Event Mesh Service instance Dashboard.
- Select Queue Subscriptions in the Left Menu.
- Click
- Provide the Queue Name and the Topic Name or Pattern which you have configured in the S/4HANA system.
Based on the configuration done in the S/4HANA system, the queue contains the messages with the topic name and pattern.
And we are done !!!!.
Yes, the setup steps are done. And we are ready for the consumption.
Now just subscribe your application to the queue, and you are ready to get notified (either in AMQP or in REST protocol) when a message comes to the queue.
A Picture is like thousand words. And let me finish this blog, with the below picture which highlights the E2E story of out-of-box event handling support of SAP Event Mesh with S/4HANA.
Very nice post!
Hi Pradeep,
We are trying to implement enterprise messaging from S/4 On-Premise. Could you please guide us how to configure/access Communication arrangement from On-premise system?
Regards
Baskaran K
Hi Baskaran,
Thanks for the question.
Whatever i have mentioned here is in terms of communication arrangement is for S/4HANA Cloud backend system.
Should you intend to implement enterprise messaging form S/4HANA On-Premise, we need to make the system event aware. And that can be achieved through Configuring Enterprise Event Enablement
Request you to follow the steps given there and proceed.
Should you still get stuck somewhere, do not hesitate to use this platform to let us know.
regards
Pradeep
Pradeep,
Hope you are doing well.
Is there any pre-requesite in regards to the S4HANA On-Premise version for configuring Enterprise Event Enablement? We are in 1610 and not sure if this is possible.
Thanks!
C.
Hi Charles,
Do follow this blog. 1809 is minimum required.
regards
Pradeep
Many thanks Pradeed,
It seems we are not in the minimum released required.
Do you happen to know if it is possible to enable the events in a trial account for S4HANA Cloud?
Regards and many thanks for your help again.
C.
Hi Charles,
As of now "default" type SAP Cloud Platform Enterprise Messaging is not available in Trial Environment.
regards
Pradeep
Hello Pradeep,
Great Blog, you made my life a lot easy.
Do you have the next steps on how to create an application and how to subscribe to the Queue?
"Now just subscribe your application to the queue, and you are ready to get notified (either in AMQP or in REST protocol) when a message comes to the queue."
Thanks in advance for your help.
Regards
Guru
Hi Guru,
Thanks you liked the post.
With the configuration mentioned above, messages will be published to queue against the configured event, when that event occurs.
Now the application should be able to consume the message from the queue. And there are examples in git hub which helps on consuming messages from queue.
In case you are using node.js, follow this messaging client sample to consume the message from the queue.
And if you your program is in Java , corresponding messaging client sample is here.
regards
Pradeep
Dear Pradeep,
I did setup the OP "Enterprise Event Enablement" and was able to connect it with the event administration of the EM service.
I configured the event topics OP like this for testing.
As I do not have any application I just created a queue and subscribed to the topic "PS4".
Now doing any change on the BOs defined before (SO or BP for example), nothing ends up in the EM queue at all.
Do you have any hint what I missed?
Best Regards,
Florian
Hi Florian,
You need to provide the pattern as PS4/* or PS4/BO/* and try.
regards
Pradeep
Hi Pradeep,
thank you for that tip. Unfortunatelly no change. I do not see any incoming messages in the queue.
Best Regards,
Florian
Hi Florian,
Have you checked if these particular business objects are active in the “Business Events Subscription”?
If YES, then please try just * in queue_subscription. Need to confirm if messages are coming at all to any topic.
regards
Pradeep
regards
Pradeep
Hi Pradeep,
checked, I activated all SCP related ones and changed the SCP Queue subscription to * but still nothing.
Best Regards,
Florian
Hi Florian,
Asynchronous Communication sometimes is little tricky. :).
I would prefer you to opt for the second option (which you most probably have done)
and then please activate the BUSINESS OBJECT associated with Enterprise Eventing subscriber. Below snapshot is an example in one of our systems in which Sales Order change event has not been subscribed with Enterprise Event.
I assume this time you will be able to resolve the issue and can share a smile.
regards
Pradeep
Hi Pradeep,
a big 🙂 for your highly appreciated help.
In our 1809/FPS01 system there is are just two types of subscribers. SCP1 and OT01. All for SCP1 are acvtive but nothing reaches the SCP EM queue
Best Regards,
Florian
Hi Pradeep Panda ,
I have a webhook subscription created for the EMS instance.
The endpoint is a simple NodeJS app which expects a POST request. I am logging the request that arrives i.e printing its body. However, when I check the log I see that an empty body is printed whenever a event is triggered.
I checked the availability of the event’s contents using REST API in Postman. It works. I can see the event’s contents. But the same content is not being passed in webhook call.
Hi Boudhayan,
Would mail you separately. Most probably we need to have a discussion to dig deeper.
Once we get the resolution, we shall provide the solution here to help other developers' who are facing similar issues.
regards
Pradeep
Hi Pradeep,
Thanks for this blog!
I have a question on the below scenario depicted in the image(Micoservice sends a message to EM and EM passes this message to S4 HANA On-premise system), can S4 HANA on premise system receive message via Enterprise messaging? I am trying to find the configuration for this in SPRO under SAP Netweaver->Enterprise Event Enablement but unable to find a suitable configuration for this scenario.
Bennet
Hi Bennet,
S/4HANA On Premise system as such can not receive message from SAP Enterprise Messaging.
However as Enterprise Messaging also has a REST Endpoint, you can configure this as an HTTP Destination in your ABAP system and perform the polling to read messages from EMS queues.
Hope it clarifies.
regards
Pradeep
Hi Pradeep,
I think the better option would be to use the webhook of enterprise messaging as this avoids polling.
Best regards
Gregor
Hi Pradeep Panda ,
Can SAP Commerce publish as well as subscribe to events via Enterprise Messaging service ?
For example, SAP Commerce B2B portal can be a subscriber for all events to notify the customers of say order delivery delays etc & SAP Commerce B2B portal can also be the publisher for event like Order placed or return initiated etc.
Thanks,
Suchita
Hi Suchita,
As such no out of box support is available as of now which is possible from S/4HANA as mentioned above.
However SAP Enterprise Messaging supports open standard messaging protocols and allows you to use client libraries for Java and Node.js. Hence, if SAP Commerce supports any of the below link protocols, it should be able to publish messages to SAP Enterprise Message.
https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/3f424ff1ae3b4bc084c4f1ea0be96f54.html
regards
Pradeep
hi,
I am facing issue in S4 HANA on-premise system 1809,
Channel is created, event are triggering but messages are not available in trail cloud foundry account.
there is no error in /iwxbe/error_log
But could not able to recieve messages in CF account queue. Through Post man if we are trying to post messages those are appearing in CF queue.
Could you please help.
Hi ,
Can you check /IWXBE/C_EVENT ? Filter with channel name and see the status of the message.
Looks to me a set up issue with S/4HANA and not related to Enterprise Messaging.
regards
Pradeep
Hi Pradeep,
How to get OAuth2.0 service on trial account ? I was following the steps you mentioned. But when i test outbound services on communication arrangement S4 HANA cloud is not able to reach the messaging service on SCP. I am getting the following error. 'Verify Outbound service and outbound URL'. URL looks fine to me. When i checked OAuth service on the trial account, i don't see the OAuth option at all. It doesn't give me option to subscribe either. Is that a limitation on the trial account ?
Regards
Ashis
Hi,
You need to use factory account as SAP Enterprise Messaging "default" instance is not available in trial environment.
regards
Pradeep
Hi Pradeep,
I had no issues setting up the Enterprise Messaging in my Trial account and connecting it to an S/4HANA on Premise system using the documentation for Enterprise Event Enablement. I've got the required keys for the OAuth Setup from the service keys section:
You can check out the result in this video: Catching SAP S/4HANA on premise Business Events via a Webhook.
Best regards
Gregor
Hi Pradeep- Your blog helped me a lot.
the enterprise event subscriber is empty in business event manager, Do I miss anything here?
Cheers,
Karthik Arjun
Hi Karthik,
Can you please share the steps you have performed and what issue exactly you are facing ?
regards
Pradeep
Hi Pradeep Panda,
As per your comment above-
With the S/4HANA 2008 release, the configuration which needs to be done has changed. Hence, instead of following the S/4HANA configuration as mentioned below, please follow this blog to perform the required configuration.
Using SAP S/4HANA Cloud Extensibility Service to the configuration is an alternative way to what S/4HANA configuration as mentioned above? OR it's no more supported and we have to go with S/4HANA Cloud Extensibility Service?
Regards,
Anuja
Hi Anuja,
Hope you got the required help/guidance from our side. As discussed over the call, please try and let us know if you still face any problem.
regards
Pradeep
Pradeep-
Hope all is well. I am working on a scenario using CPI. I have a sales order being sent to S4HC. I am working on creating an event mesh to send the created sales order information.
I am using S4HC SAP S/4HANA CLOUD 2202 cloud, I am seeing that the enterprise enablement package is reverted back to what you have mentioned in the blog. Do you have any specific updates regarding this and also if I should be able to receive a SO if follow the steps that you have mentioned above correct? additionally is there any specific steps that need to be considered.
Please let me know.
Regards
HS
Hi Hari,
You are correct. Things have changed since the blog has been written. And hence in the blog we have added following line.
With the S/4HANA 2008 release, the configuration which needs to be done has changed. Hence, instead of following the S/4HANA configuration as mentioned below, please follow this blog to perform the required configuration.
Have you followed this blog ?
regards
Pradeep
Amazing blog Pradeep Panda
I have a query regarding de message client concept and I would be very grateful if you could clarify.
We have an escenario where some Non SAP applications will be consuming events triggered by S4Hana Cloud. At the same time, these Non SAP systems will be creating evhhents/messages for further consumption by S4Hana Cloud and other Non SAP systems.
A message client has been already created when I created an instance of S4Hana Cloud Extensibility Service with plan messaging.
My question, do I need to create a Message Client with its own namespace for each of the Non SAP Applications? I understand that for doing so, I need to create an instance of Event Mesh at space level? Are there any licensing implications for the number of event mesh instances or what matters is the size of the messages transferred regardless the number of instances?
Many thanks in advance.
Regards,
C.
Hi C,
An EMS service instance is essentially a client with clearly defined permissions. If you have one app (app1) that only publishes events to topic 'A' and another app (app2) that only consumes those cloud events, you may create one client (service instance) per app .
Here is the pricing strategy.