Skip to Content
Product Information
Author's profile photo Makoto Sugishita

How to use SAP S/4HANA Event Enablement with SAP Cloud Platform (EN)

<<Japanese version is here>>

1. Introduction

This blog is the fourth in a blog series on “How to extend SAP S/4HANA with SAP Cloud Platform” and I will explain about S/4HANA Event Enablement here.  With this Event Enablement feature, we can trigger an external logic only when an event occurred in SAP S/4HANA. This event here means  Business Object “Create”, “Change” or “Delete”.

  1. Overview of extended development on SAP Cloud Platform
  2. How to find SAP S/4HANA API
  3. How to use SAP S/4HANA API
  4. If API does not exist (will come later)
  5. Event integration with SAP S/4HANA <<<<HERE

Generally, for the custom development of SAP S/4HANA, it is recommended to follow the  “Keep the Core Clean” principle. In other words, we need to have a clear distinction between the SAP standard application and custom development objects. The extension inside of S/4HANA (In-App Extensibility) will be limited to an extension with a specific tool like a “Key User Tool”. And we will put the custom development objects outside of SAP S/4HANA and that is called Side-by-Side extension.

It might be easy to imagine how it works when you develop something (e.g. user interfaces or business logics ) on SAP Cloud Platform and accessing to SAP S/4HANA API. As introduced in Susumu’s previous blog, you can get or create data with OData API in SAP S/4HANA. It is also possible to use SAP Cloud SDK which is a wrapper library of OData API there.

 Accessing to SAP S/4HANA API from SAP Cloud Platform

On the other hand, what if we want to trigger some action externally when an object of SAP S/4HANA is created or changed? It is still technically possible to check the object creations or changes by polling API calls at regular intervals, but the real-time integration may not be achievable with that.
Event-based integration comes up here.

An event in SAP S/4HANA will trigger an external logic in SAP Cloud Platform to be executed

By using this method, it is possible to start an external logic or start data/process integration when the SAP S/4HANA object is created.

In past, you would have updated the data with EXIT or BADI of SAP S/4HANA. You may be able to achieve the similar thing with the event-driven fashion with this.


SAP S/4HANA and SAP Cloud Platform Enterprise Messaging According to the Event Driven Architecture

Let’s take a closer look.
The architecture may look like this.

Events that occur in S/4HANA are sent to SAP Cloud Platform Enterprise Messaging.
It is also possible to broadcast from Enterprise Messaging to multiple runtimes.

In the diagram above, three types of systems (SAP Cloud Platform Integration, Extension Factory Serverless Runtime and web application) receive data from Enterprise Messaging, but you can freely decide which system receives it.

I will briefly introduce each component.

1.SAP S/4HANA Enterprise Event Enablement feature








With the feature of Enterprise Event Enablement of S/4HANA, you can pass the S/4HANA event to the external systems via the middleware called SAP Cloud Platform Enterprise Messaging. The  supported communication protocol between SAP S/4HANA and SAP Cloud Platform Enterprise Messaging will be MQTT (over Websocket).

2.SAP Cloud Platform Enterprise Messaging

SAP Cloud Platform Enterprise Messaging is a middleware service for asynchronous messaging. By placing Enterprise Messaging in between, it is possible to realize asynchronous messaging that separates the sending process and the receiving process, and to level the message processing load.

3.SAP Cloud Platform Extension Factory, Serverless Runtime







SAP Cloud Platform Extension Factory, Serverless Runtime is a runtime for building a serverless environment in SAP Cloud Platform. Just like an ordinary serverless environment like AWS Lambda, it is possible to execute logic in an event-driven manner and you don’t need to care about server resources or sever management.

4.SAP Cloud Platform Integration







SAP Cloud Platform Integration is a middleware service for the Process Integration (iPaaS) on SAP Cloud Platform. Currently, multiple Integration services (Cloud Platform Integration, API Management, Open Connector) have been integrated and are now offered as an Integration Suite.  SAP Cloud Platform Integration is the core component of it.


Another important point for the we don’t pass the entire data of the business object for the event messaging.The payload of the event only includes the type of business object (Purchase order, Sales Order etc.), key information, and action( creation, change, or deletion).

Here is an example of the palyload.
We can know this is en event of Outbound Delivery Change and the document number is “00800005”.


Enterprise Messaging will simply pass the payload data just as it is and  when you received it with SAP Cloud Platform Integration, Serveless Runtime or custom application, it is necessary to pass the kay and access the API of S/4HANA to get the detailed information.


.SAP S/4HANA integration with SAP Cloud Platform Enterprise Messaging

From here, I will explain about the actual configuration in Step by Step.

Most of the steps are similar to this blog. One thing we need to remember is the blog below is using “trial” version of SAP Cloud Platform and the “plan” of Enterprise Messaging is different from the productive version.

For this blog, I will use the plan for the production environment.

OK, then let’s start with the configuration on SAP Cloud Platform.

3.1 CLI Download and Login

In this blog, I will create the the service instance of Enterprise Messaging via CLI (Command Line interface) tool instead of the SAP Cloud Platform Cockpit Web screen.

If you have never used the Cloud Foundry CLI, I would recommend you to install it on your PC and try it out.

Click here to download Cloud Foundry CLI

This is the tutorial about the Cloud Foundry CLI and you will know how to login with CF CLI here.


3.2 Create a Service Instance

Let’s create a configuration file for creating a service instance of SAP Cloud Platform Enterprise Messaging. It is a JSON format text file like below on the local PC and name it “param.json”.

    "options": {
        "management": true,
        "messagingrest": true,
        "messaging": true
    "rules": {
        "topicRules": {
            "publishFilter": [
            "subscribeFilter": [
        "queueRules": {
            "publishFilter": [
            "subscribeFilter": [
    "version": "1.1.0",
    "emname": "EM1",
    "namespace": "SAPJP/EM1/S4HANA"

Create a service instance “em1” with the following command.
cf create-service enterprise-messaging default <service instance name> -c <option>

cf create-service enterprise-messaging default em1 -c param.json

Use the “cf service” command to check if the service was created successfully.
You can get information about the service instance with
cf service-<service instance name> .

cf service em1

name:             em1
service:          enterprise-messaging
plan:             default
description:      Connect applications, services and systems across different landscapes.
service broker:   sm-enterprise-messaging-service-broker-a6a59ffd-b691-49b4-b439-d4960acc2065

Showing status of last operation from service em1...

status:    create succeeded
started:   2020-05-24T23:39:31Z
updated:   2020-05-24T23:40:33Z

There are no bound apps for this service.

Upgrades are not supported by this broker.


3.3 Create a Service Key

When you use a service from an application, you can get the access information from the environment variable of the app by binding the app to the service. But if you want to access from an external system like this S/4HANA, we need to create a service key to get the access info.

Create the service key with the following command:
You can create a service key with cf create-service-key <service instance name> <service key name> .

cf create-service-key em1 em1-key

3.4 Get the Service Key

Specify to get access information from the service key.

Information can be obtained with cf service-key <service instance name> <service key name> .

cf service-key em1 em1-key

 "management": [
   "oa2": {
    "clientid": "<client id value>",",
    "clientsecret": "<client secret value>",
    "granttype": "client_credentials",
    "tokenendpoint": "https://<tenant>.authentication.<region>"
   "uri": "https://enterprise-messaging-hub-backend.cfapps.<region>"
 "messaging": [
   "broker": {
    "type": "sapmgw"
   "oa2": {
    "clientid": "<client id value>",
    "clientsecret": "<client secret value>",
    "granttype": "client_credentials",
    "tokenendpoint": "https://<tenant>.authentication.<region>"
   "protocol": [
   "uri": "wss://enterprise-messaging-messaging-gateway.cfapps.<region>"
   "broker": {
    "type": "sapmgw"
   "oa2": {
    "clientid": "<client id value>",
    "clientsecret": "<client secret value>",
    "granttype": "client_credentials",
    "tokenendpoint": "https://<tenant>.authentication.<region>"
   "protocol": [
   "uri": "wss://enterprise-messaging-messaging-gateway.cfapps.<region>"
   "broker": {
    "type": "saprestmgw"
   "oa2": {
    "clientid": "<client id value>",,
    "clientsecret": "<client secret value>",,
    "granttype": "client_credentials",
    "tokenendpoint": "https://<tenant>.authentication.<region>"
   "protocol": [
   "uri": "https://enterprise-messaging-pubsub.cfapps.<region>"
 "namespace": "sap/scp/em1",
 "serviceinstanceid": "7dbde612-2898-4001-a868-2f1ff8cbb03c",
 "xsappname": "default-7dbde612-2898-4001-a868-2f1ff8cbb03c-clone!b57|xbem-service-broker-!b25"


In the information above, you can find three types of access information, AMQP, MQTT, and HTTP REST. In particular, MQTT is used to connect from S/4HANA, so let’s take a note of the MQTT information.

  • URI
  • Client ID
  • Client Secret
  • Token Endpoint

3.5 Download Certificate File

Access Enterprise Messaging Token Endpoint from the browser and drop the certificate.

From here, let’s try the SAP S/4HANA configuration.

3.6 Importing the certificate

t-code STRUST





Double click SSL client SSL Client (Standard)



Import the file downloaded in 3.3

In t-coe SMICM, restart the (ICM) server alone or restart the entire ABAP system.


3.7 Move to channel related settings

T-code SPRO “SAP Reference IMG”

SAP NetWeaver-> Enterprise Event Enablement->Administration->Channel Connection Settings

3.8 HTTP Destination Creation

Select “Manage RFC Destination” to create an HTTP destination

Click “Create” button to create a new HTTP destination (connection information to SAP Cloud Platform Enterprise Messaging).

Connection Type should be “G” (HTTP Connection to external server).

Enter the host name (without “wss:///”) and the path using the ” uri ” of the Service Key information above .

In Logon and Security Tab, change the SSL setting to be Active and select the DEFAULT SSL Client(Standard) where the certificates were imported in t-code STRUST.

3.9 OAuth Client Setup

OAuth Client Credential Flow is used for authentication from SAP S/4HANA to Enterprise Messaging and we will create the OAuth client setting.
Click “Manage OAuth 2.0 Account Client Setup”


A new browser window will open, enter your user ID and password to log in to the system.

Once you are logged in, press “Create”.

Select “/IWXBE/MGW_MQTT” for the profile and enter the Configuration name freely.
Enter the clientid of the Service Key to the OAuth 2.0 Client ID and press OK.

Set Client Secret (clientsecret in the service key).

For the authorization endpoint replace “token” of token endpoint with “authorize”
Please do not enter “https://” as it is already there

Select “Header Field” and “Client Certificate”

Press “Save”.


3.10 Channel Creation

Click “Manage Channel and Parameters”


Press “New entries” to add a new entry and enter the Channel Name, Destination name, Topic space and description.
Channel Name: Arbitrary value
Protocol: MQTT_311_WS
Destination: HTTP destination created in 3.8
Topic space: This needs to match to the Enterprise Messaging Namespace.

Select the entry and double-click “Parameters”.


Press “New Entries” and add the parameters.

Enter the name entered in 3.9 above for OAUTH_20_CONFIGURATION.

Enter a fixed value of /IWXBE/MGW_MQTT for OAUTH_20_CLIENT_PROFILE.

You can add some other parameters based on the requirements.

Press this button to switch it to display mode.

Click “Active<->Inactive” to activate it.


3.11 Check the service settings













Make sure there is an entry for Service: IWXBE, Enablement Service Registry: CL_BEH_SERVICE.

3.12 Event topic setting

Select “Maintain Event Topic”.













Enter the channel name created in 3.10 and press enter.

Enter a new entry for Business Object Event.

If you enter “BO/OutboundDelivery/*” as shown below, all events (create, change, delete) of Outbound Delivery Document will be captured.


From here you work with SAP Cloud Platform Cockpit.

3.13 SAP Cloud Platform Enterprise Messaging Subscription

Select subaccount and select “Subscription” from the menu.

Click “Go to Application”.


On the Enterprise Messaging Admin page, click Message Client.

You can see the service instance created with CF CLI before.

Select “Create Queue”.

Create it with any name.

The Queue created here is the setting of this red frame part in the figure below.


Next, make a subscription from Queue to Topic.

Click “Action” and select #Queue Subscriptions”.










As I have configured in the S/4HANA side, we want to subscribe to the Topic for the Outbound Delivery Document this time. “*” means  all of “create”, “change” and “delete” event again.





















With this setting, the Queue is now subscribing to the Topic, and messages entering the Topic will come to the Queue.
This configuration is the connection part inside the red frame in the figure below.


If you want to make an HTTP request to the outside when a message enters the Queue, you can also create a webhook. This setting is not necessary when sending with AMQP.

Let’s create another Queue and set the webhook.
Go to the Webhooks tab and press “Create Webhook”.

Create it by giving the subscription name and entering the destination URL.













Since it is in the paused status at the first creation, select the “Resume” button from the drop-down list to resume it.



.Receiving system side settings etc.

I will omit the details of the setting to receive Queue with AMQP over websocket, but let’s highlight the screenshot here.

Here is the trigger settings in SAP Cloud Platform Extension Factory, Serverless Runtime

Add using the set Queue name.

Connect using the service key information.

This is the sample code for receiving data from Enterprise Messaging.

4 Conclusion

It is getting more important to think about asynchronous messaging using Event for the future system architecture.This blog is about S/4HANA On-Premise and SAP Cloud Platform but similar concept will come to the other solutions as well. I hope everyone can get the rough idea how the event based messaging works.
And please give it a try!

Enterprise Messaging Developer Tutorial

S/4HANA On-Premise Enterprise Event Enablement Online Help

SAP Cloud Platform Enterprise Messaging Online Help

SAP Cloud Platform Extension Factory Serverless Runtime Online Help

SAP Cloud Platform Integration Online Help


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Dominik Kuhlmann
      Dominik Kuhlmann

      Great Blog!

      Is it possible to extend the payload in enterprise messaging by specifying the source system and source clients (in the case of S/4HANA Enterprise Event Messaging)?

      Or maybe to use the "source" tag within the payload for that?

      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      Hi Dominik,

      Thank you and sorry that i did not notice the comment.

      As far as I checked, there is no way to change the payload value of source yet.

      Best regards,


      Author's profile photo Rohit Jha
      Rohit Jha

      Hi Makoto,

      First very nice and descriptive blog and  you deserve   all the kudos.

      Now I am facing an issue in my config and need some help.

      I have done all this configurations in S4H on-prem system and while it works when I fire a test

      message for the  test event service  /IWXBE/EVENT_DEMO   and I can see an entry in table /IWXBE/C_EVENT and mesage goes to SCP EM queue. So connectivity is good.

      But when same channel I use to send the BO based events ike BP create via IWBXE (CL_BEH_SERVICE) it doe not write to this table and send the message to EM queue on SCP.

      Can you please help here to understand what could be the issue here? Many thanks, Rohit

      Attaching screenshoterror



      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      Hi Rohit,
      Sorry that I did not notice this question.
      Can you check if this Q&A will be relevant to the problem?
      Best regards,

      Author's profile photo E. Palmen
      E. Palmen

      When I set the channel to active we get an certificat error. Untrusted chain. We added the chain in STRUST restarted ICM and even restarted the system.

      But still no luck.
      any help would be welcome

      regards Erik

      Author's profile photo E. Palmen
      E. Palmen

      It's working the certificates should be placed in STRUST SSL-client(anonymous) .

      Author's profile photo Luc VANROBAYS

      Hi Makoto,

      nice detailed blog,

      how is your use-case different from the one announced below and requiring NW Event Enablement Add-on ?


      Event-driven architecture – now available for SAP ECC users




      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      Hi Luc,

      Thank you for your comment.

      With the enhancement of NW, we now can use the Event Enablement feature also with ECC.



      Author's profile photo Praveen Varriam
      Praveen Varriam

      Hi Makoto,

      Very informative and deep analyzed blog !

      I have tried by myself and able to successfully trigger events to SCP EM queue.

      I was wondering if the Business Events from S/4HANA can be triggered to any other 3rd party Event broker in cloud using RESTful service.

      If yes, could you please let me if by changing the RFC Destination and importing of required certificate (STRUST) will suffice ?




      Author's profile photo Michael Walker
      Michael Walker

      I have the same question.  It seems likely since I don't see anything that looks to be Enterprise Messaging specific technology.  But it would be nice to get that confirmation.

      Author's profile photo Arpi Thakkar
      Arpi Thakkar

      I have the same question. Did any one of you get the way to trigger Business Events from S/4 HANA to any other Event Broker in cloud using RESTful service ?
      Do we have any option to read the Business Event output JSON file directly using any REST service ?

      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      Hi all,

      Thank you for your comments and sorry that I did not repond.

      Here, there is a description like below.

      Events from SAP S/4HANA can only be sent to SAP Business Technology Platform (SAP BTP), Enterprise Messaging, where they can be used by any recipient.

      So I think this feature will basically expect S/4HANA to send the messages to Enterprise Messaging.
      EM can forward the messages to the 3rd party software with Webhook or via CPI.

      Best regards,


      Author's profile photo Vijay Konam
      Vijay Konam

      Thanks for the excellent blog Makoto. However, while using industry standard protocols, why SAP chose to restrict this to work with only SAP BTP EM? Many organizations use Service Bus provided by a hyper scalar and are very much reluctant to enable and Event Broker on a different cloud altogether. Hope SAP opens this up!

      Vijay Konam

      Author's profile photo Ariel Bravo Ayala
      Ariel Bravo Ayala

      Hi Makoto,

      Thanks for such a detailed blog. I would like to know if it is possible to create "Z" events. If so, where can I find the relevant documentation?

      Thanks again,



      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      Hi Ariel,
      Unfortunately it seems the ABAP classes for the Eventing are not released to our customers for now.

      Best regards,


      Author's profile photo Ariel Bravo Ayala
      Ariel Bravo Ayala

      Thanks Makoto for the update, it is a pity 🙁

      Out of curiosity, could you share the name of the package where the standard ABAP classes are located? Thanks again.


      Author's profile photo Makoto Sugishita
      Makoto Sugishita
      Blog Post Author

      The standard package name will be "/IWXBE/CORE_RT".
      Again it is not supported to use these classes for now.

      Author's profile photo Rayudu Sureshji
      Rayudu Sureshji

      Great blog! I followed all the steps and enabled events from S/4 on premise to Event Mesh, but the events I'm receiving are having a default Content-type "application/octet-stream". In S/4 I see the text Biresin® M70, where as in Event Mesh I see it as Biresin® M70.

      Could you please help me where should I config content type to "application/json" ??

      Author's profile photo Daniel Wagner
      Daniel Wagner

      Why is there a limitation to SAP Event Mesh, I'd really like the design to be more open - as it seem's to make use of standard protocols. All major hyper-scalers provide messaging services which support these standard protocols, we, and presumably many other customers, would prefer to source PaaS elements like a queue from there.

      Author's profile photo Heike Raschdorf
      Heike Raschdorf

      Thanks for this great blog!

      I have currently trouble with the RFC Destination to EM in the cloud.

      All the cloud certificates were added to SAPSSLC.pse. Do I have to add certificate of SAP System as well in the cloud? If yes, I would be very thankful for guideance.

      This is the error message (region and subaccunt replaced by "xxxx").

      [Thr 139687129069312] *** ERROR => SSL handshake with failed: SSSLRC_CONN_CLOSED (-10)
      [Thr 139687129069312] Remote Peer has closed the network connection
      [Thr 139687129069312]
      [Thr 139687129069312] SapSSLSessionStartNB()==SSSLRC_CONN_CLOSED