RAP Business Events with Advanced Event Mesh [1]: Connecting AEM to S/4HANA On Premise 2023

Estimated read time 11 min read

This series of blogsΒ intends to show in a step-by-step way the different possibilities to use RAP Business Events with Advanced Event Mesh.

Β 

Overview

In this first blog, we’re going over the basic integration to connect Advanced Event Mesh to S/4HANA On Premise 2023. We are going over the required setup to connect the two and configuration to send standard business events, in this specific case the business partner changed event, from the S/4HANA system the the Advanced Event Mesh.

Β 

Connect Advanced Event Mesh to S/4HANA On Premise

To connect the Advanced Event Mesh to the S/4HANA On Premise system two destinations have to be created within the transaction SM59. One for the AEM broker (mr-connection-*.messaging.solace.cloud) and one for the validation service (em-pubsub-broker). While the destination for the AEM broker has to be setup manually, the destination for the validation service can be setup automatically via the service key from the BTP.

For the AEM Broker destination a host URL and port is required. These can be taken from the AEM UI. Go to β€œCluster Manager” and select the β€œConnect” tab. Next select β€œView by Protocol”, click on the protocol β€œAMQP” and select one of the client libraries to view the host URI.

Next open transactionΒ SM59 and create a new destination with type G. Enter the host and port copied from the AEM UI. While the relevant protocol is AMQP, the host URL in S/4 needs to have the protocol manually adjusted to β€œtcps://”. The destination should therefor look as follows:

Next select the tab β€œLogon & Security” and set SSL to Active.

The Enterprise Event Enablement integration within S/4HANA uses Client Certificate Authentication to connect to the AEM. Therefore the next step is to export the necessary certificates from S/4HANA and import them to the AEM.

For that first remember the SSL Client PSE ID given in the Destination Setup (here β€œDEFAULT SSL Client (Standard)”). It can be found under β€œSecurity Options” > β€œStatus of Secure Protocol”.

Next open the transaction STRUST and navigate to the same SSL Client node given in the destination setup. Select your systems own certificate and export it as base64. Also remember the common name (CN) of the certificate (here T33_SSLC_DFAULT) as we need it later.

In the Advanced Event Mesh Cluster Manager select your broker, under the β€œManage” tab go to β€œAuthentication” and enable β€œClient Certificate Authentication”.

Next lets upload the client certificate. For that go back to the overview of the β€œManage” Tab within the event broker and select β€œCertificate Authorities”. Click β€œAdd Client Certificate Authority” and upload the previously exported certificate.

Once again go back to the β€œManage” tab of the Event Broker, select β€œAccess Control” and go to the β€œClient Usernames” tab.

Create and enable a new β€œClient Username” which matches the previously looked at common name (CN) in the certificate (here T33_SSLC_DFAULT). This concludes the setup of the first destination.

Β 

To setup the validation service destination start by locating the service key of your aem-validation-service. For that go into your BTP subaccount and locate your AEM instance under β€œInstances and Subscriptions”.

Β 

Next go to transaction /IWXBE/CONFIG in your S/4HANA system. Create a new channel via β€œService Key” > β€œAdvanced”.

Β 

Give the channel configuration a name, description and select the destination created before (here named AEM_BROKER_CONNECTION). Paste the service key from the BTP cockpit into the adjacent field. Then hit β€œSave configuration” or press β€œEnter” to create the channel. Afterwards activate the channel. This will also create and activate a deamon responsible for keeping the connection to AEM open and processing the events. This concludes the setup.

After the channel has been created a connection check can be performed to verify the setup. If everything is working as expected there will be two new active AMQP connections in the AEM dashboard under β€œClients” in the β€œManage” tab of the event broker. One for publishing and one for receiving events.

Β 

Publish a standard business event from the S/4HANA system to the AEM

To publish a standard event to the AEM you will need to create a topic binding on the channel created in the previous section. In this tutorial we will bind the standard Business Partner Changed event to the AEM.

In the transaction /IWXBE/OUTBOUND_CFG locate your AEM channel and click β€œCreate new topic binding”. To bind the event insert the event name into the dialog and press save. The name of all standard events and their exact payload structure can be found on SAP Business Accelerator Hub. For the topic binding remove the leading β€œce/”. In the case of the business partner changed event this would mean using β€œsap/s4/beh/businesspartner/v1/BusinessPartner/Changed/v1” for the binding. Additionally wildcards (*) can be used to reference multiple different events or event versions. β€œsap/s4/beh/businesspartner/v1/BusinessPartner/*” can be used to bind all business partner events. So lets use β€œsap/s4/beh/businesspartner/v1/BusinessPartner/Changed/*” to bind all versions of the business partner changed event.

Next create a new Queue in the AEM. Go to Queue within the Event Broker and click β€œQueue” and give it a name.

Β 

After creation click on the queue and navigate to β€œSubscriptions”. Now subscribe to the topic that was bound to the AEM channel in your S4 system. It is important to note that standard events published by S4 will always include the namespace that was given during channel creation in the topic. By default this is β€œS/4HANA/Events”. This time however β€œ/ce” is included within the topic to denote that the event is CloudEvent.io conform.

Β 

Making a change to a business partner within transaction BP will now trigger an event that is being bound by the created channel. The Enterprise Event Enablement will then perform a handshake with the VMR/validation service to confirm that the AEM broker is a valid SAP broker and afterwards push the event. Since the created queue is subscribed to the topic of business partner changes the event will be queued. This can be verified by looking at the β€œMessages Queued” within the queue.

Β 

Β 

Β 

Β 

​ This series of blogsΒ intends to show in a step-by-step way the different possibilities to use RAP Business Events with Advanced Event Mesh.Β OverviewIn this first blog, we’re going over the basic integration to connect Advanced Event Mesh to S/4HANA On Premise 2023. We are going over the required setup to connect the two and configuration to send standard business events, in this specific case the business partner changed event, from the S/4HANA system the the Advanced Event Mesh.Β Connect Advanced Event Mesh to S/4HANA On PremiseTo connect the Advanced Event Mesh to the S/4HANA On Premise system two destinations have to be created within the transaction SM59. One for the AEM broker (mr-connection-*.messaging.solace.cloud) and one for the validation service (em-pubsub-broker). While the destination for the AEM broker has to be setup manually, the destination for the validation service can be setup automatically via the service key from the BTP.For the AEM Broker destination a host URL and port is required. These can be taken from the AEM UI. Go to β€œCluster Manager” and select the β€œConnect” tab. Next select β€œView by Protocol”, click on the protocol β€œAMQP” and select one of the client libraries to view the host URI.Next open transactionΒ SM59 and create a new destination with type G. Enter the host and port copied from the AEM UI. While the relevant protocol is AMQP, the host URL in S/4 needs to have the protocol manually adjusted to β€œtcps://”. The destination should therefor look as follows:Next select the tab β€œLogon & Security” and set SSL to Active.The Enterprise Event Enablement integration within S/4HANA uses Client Certificate Authentication to connect to the AEM. Therefore the next step is to export the necessary certificates from S/4HANA and import them to the AEM.For that first remember the SSL Client PSE ID given in the Destination Setup (here β€œDEFAULT SSL Client (Standard)”). It can be found under β€œSecurity Options” > β€œStatus of Secure Protocol”.Next open the transaction STRUST and navigate to the same SSL Client node given in the destination setup. Select your systems own certificate and export it as base64. Also remember the common name (CN) of the certificate (here T33_SSLC_DFAULT) as we need it later.In the Advanced Event Mesh Cluster Manager select your broker, under the β€œManage” tab go to β€œAuthentication” and enable β€œClient Certificate Authentication”.Next lets upload the client certificate. For that go back to the overview of the β€œManage” Tab within the event broker and select β€œCertificate Authorities”. Click β€œAdd Client Certificate Authority” and upload the previously exported certificate.Once again go back to the β€œManage” tab of the Event Broker, select β€œAccess Control” and go to the β€œClient Usernames” tab.Create and enable a new β€œClient Username” which matches the previously looked at common name (CN) in the certificate (here T33_SSLC_DFAULT). This concludes the setup of the first destination.Β To setup the validation service destination start by locating the service key of your aem-validation-service. For that go into your BTP subaccount and locate your AEM instance under β€œInstances and Subscriptions”.Β Next go to transaction /IWXBE/CONFIG in your S/4HANA system. Create a new channel via β€œService Key” > β€œAdvanced”.Β Give the channel configuration a name, description and select the destination created before (here named AEM_BROKER_CONNECTION). Paste the service key from the BTP cockpit into the adjacent field. Then hit β€œSave configuration” or press β€œEnter” to create the channel. Afterwards activate the channel. This will also create and activate a deamon responsible for keeping the connection to AEM open and processing the events. This concludes the setup.After the channel has been created a connection check can be performed to verify the setup. If everything is working as expected there will be two new active AMQP connections in the AEM dashboard under β€œClients” in the β€œManage” tab of the event broker. One for publishing and one for receiving events.Β Publish a standard business event from the S/4HANA system to the AEMTo publish a standard event to the AEM you will need to create a topic binding on the channel created in the previous section. In this tutorial we will bind the standard Business Partner Changed event to the AEM.In the transaction /IWXBE/OUTBOUND_CFG locate your AEM channel and click β€œCreate new topic binding”. To bind the event insert the event name into the dialog and press save. The name of all standard events and their exact payload structure can be found on SAP Business Accelerator Hub. For the topic binding remove the leading β€œce/”. In the case of the business partner changed event this would mean using β€œsap/s4/beh/businesspartner/v1/BusinessPartner/Changed/v1” for the binding. Additionally wildcards (*) can be used to reference multiple different events or event versions. β€œsap/s4/beh/businesspartner/v1/BusinessPartner/*” can be used to bind all business partner events. So lets use β€œsap/s4/beh/businesspartner/v1/BusinessPartner/Changed/*” to bind all versions of the business partner changed event.Next create a new Queue in the AEM. Go to Queue within the Event Broker and click β€œQueue” and give it a name.Β After creation click on the queue and navigate to β€œSubscriptions”. Now subscribe to the topic that was bound to the AEM channel in your S4 system. It is important to note that standard events published by S4 will always include the namespace that was given during channel creation in the topic. By default this is β€œS/4HANA/Events”. This time however β€œ/ce” is included within the topic to denote that the event is CloudEvent.io conform.Β Making a change to a business partner within transaction BP will now trigger an event that is being bound by the created channel. The Enterprise Event Enablement will then perform a handshake with the VMR/validation service to confirm that the AEM broker is a valid SAP broker and afterwards push the event. Since the created queue is subscribed to the topic of business partner changes the event will be queued. This can be verified by looking at the β€œMessages Queued” within the queue.Β Β Β Β Β Β Read MoreΒ Technology Blogs by SAP articlesΒ 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author