Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
pradeep_panda
Product and Topic Expert
Product and Topic Expert
19,292
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:




  1. 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.

  2. 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:




  1. Select the Service Key.

  2. Click on Create Service Key.



Step 3:




  1. Provide any name.

  2. Make a note of the client ID, client secret, token endpoint and base URL, then use these parameters to create a communication arrangement.

  3. Save


 

Step 4:


The newly created Service Key contains following information:




  1. clientId: This ID is used to log on to the SAP Event Mesh endpoint from outside

  2. clientsecret: This is the password to be used with the clientId.

  3. 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:




  1. Create Communication System (like defining a RFC destination)

  2. Create Communication User to access the S/4 system from the outside - this will be done during creation of communication system

  3. 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:




  1. 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:




  1. tokenendpoint replacing the last path segments with /oauth/authorize

  2. 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:




  1. Provide a unique User Name and a Description

  2. Either provide a password or click on Propose Password

  3. Save the proposed password to a save place, there is no other way to retrieve this password

  4. Complete the user creation by clicking on Create

  5. 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:




  1. Authentication Method select OAuth 2.0

  2. OAuth 2.0 Client ID from Service Instance: Eventing - Service Keys

  3. Client Secret from Service Instance: Eventing - Service Keys

  4. Create the New Outbound User

  5. 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:




  1. Scenario: select SAP_COM_0092 from the value help

  2. Provide any unique Arrangement Name

  3. 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:




  1. Give any name for the Channel

  2. Give any Description for the Channel

  3. 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>




  1. QoS (Quality of Service) = 1 (At least once)

  2. Reconnect Attempts: any amount of reconnect attempts in case of a connection error

  3. 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:




  1. In the filter provide messaging

  2. 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:




  1. Select New Entries

  2. Select the first empty line of the table and use the value help to
    open the list of available Topics.

  3. Select any of the Topics you want to add to your Channel.
    You can choose between specific Topics only or by selecting sub paths.

  4. Click on Save

  5. Click on Exit










Setup Queue Subscription to consume Event Topics to be exposed by this channel.


Step 25:




  1. Open the SAP Event Mesh Service instance Dashboard.

  2. Select Queue Subscriptions in the Left Menu.

  3. Click

  4. 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.


36 Comments