Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Hello folks,

Once again returning the topic of SAP Enterprise Messaging - Event Broker from SAP - to handle events from S4HANA - Web-hook mechanism and comparisons with Restful API's and Websockets.

Previously I release some other blogs just testing the functionalities of SAP EM - Lite plan - using POSTMAN as trigger and Restful API's you can see the references below:

Get API Blogs SAP - "Last updates - Ricardo Viana"


"Last update Ricardo Viana":{

I did this proof of concept in the LITE plan of SAP EM product that was Deprecated by SAP but the functionalities still valid for DEFAULT plan.

SAP CPI – Cloud Event Broker – SAP EM for asynchronous patterns

SAP EM – Event Broker for Events S4HANA

SAP Cloud Platform Enterprise Messaging – Making S/4HANA Event Notification Easy - pradeep.panda




Reference SAP Help document:


Reference of blogs:

I mentioned of those blogs to don't repeat the same details again, you can manage all from SAP material but if you get stuck the blogs are very good detailed reference.

Proof of Concept:

As you already understand the SAP EM it's event broker for small event messaging details to handle for example business partner, product changes and others.

After setup all environment the PoC will trigger the change in the Material Master T-CODE (MM02) of simple change in the description of the material and SAP EM must be able to receive the PRODUCT code that has been change.

Below you will see the sort cut when to use the different protocols, I'm not going deep on it because this blog will be a book you can easily find a lot of information on-line.

Integration Diagram Perspective:

Perspective of connectivity:


3rd Party - SAP EM - 3rd Party:

Sender / Receiver: Connect via Web-hook,Restful API or Web-socket (AMQP/MQTT)

S4HANASAP EM - 3rd Party:

Sender: Connect via only websocket - MQTT / Receiver: Web-hook,Restful API or Web-socket (AMQP/MQTT)

3rd Party - SAP EM S4HANA:

Sender:Web-hook,Restful API or Web-socket (AMQP/MQTT) / Receiver HTTPS and Web-socket (MQTT)


Why CPI ?


The SAP EM just contains the code of product ID that has been change and in this case SAP CPI will be responsible to receive the Web-hook (push) call and read the API from S4HANA based in the product data that has been changed any detail and replay to the third party the details of the changes.

CPI today is not able to receive the calls via MQTT web-socket but via AMQP, once SAP will delivery this upgrade you will be able to connect with SAP CPI via AMQP.

What is web-hook ?


A web-hook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. A web-hook delivers data to other applications as it happens, meaning you get data immediately. Unlike typical APIs where you would need to poll for data very frequently in order to get it real-time. This makes web-hooks much more efficient for both provider and consumer. The only drawback to web-hooks is the difficulty of initially setting them up.

When to use a Web-hook (POST - "PUSH") ?


Web-hooks are commonly used to perform smaller requests and tasks, however there are situations where a web-hook is more appropriate than an entire API.

When to use an Restful API (POST,GET,DELETE,PUT)?


APIs work incredibly well when you know you’re going to have a constant change in data. There’s no point in using an API if the data you’re requiring is going to be relatively stagnate. For example, if you’re master data management change the material details regularly then you’re going to be making constant requests.

When to use a Web Socket - AQMP & MQTT ?


Web-socket is an advanced technology that allows you to start bi-directional communication session between the browser and the server.


OK until now ?

I believe yep, let's go.


Let's go to steps now:

  1. T-code MM02

  2. Select the material

  3. Change the basic data description of the material

  4. Save the material - The event has been triggered

  5. Event Payload received in SAP EM

  6. Test proposal to check the event payload in SAP EM

  7. Web-hook setup configuration

  8. Pos setup web-hook

  9. SAP CPI - Artifact Iflow

  10. Odata or HTTP API call adapter

  11. Third Party requirement (Only fields that has been change)

Steps below:

1 - T-Code - MM02:

2 - Select the material to be change:

3 - Change the basic data description of the material - Description adding "PoC - SAP EM - Web-Hook - Viana - 04/03":

4 - Save the material - The event has been triggered:

Once you save and all setup describe in the blog or sap help is in place, the event should be triggered in background to SAP EM.

5 - Event Payload received in SAP EM:

Fast link add your instance: Add with your instance

Check in the T-CODE - /SPRO:


6 - Test proposal to consume the event payload in SAP EM:

Just for test proposal - check the values in the queue of SAP EM, in case once you consume the data the message will be delete - This steps it's just to show the json received in queue <yournamespace>/MaterialMaster:

Json event payload sample - Product has been changed - "10120764":

7 - Web-hook setup configuration:

Setup up of the web-hook:

  • subscription name

  • queue name

  • quality of service (0 or 1 ),

  • it's PoC, so I exempt the handshake

  • On premise:  OFF - I'm callback cloud platform integration - Cloud.

  • Webhook URL - Copy from SAP CPI HTTPS call:

  • User/pass from the tenant

Sample image:

8 - Pos setup web-hook:

Click and "Actions" --> Trigger Handshake even if you exempt and --> Resume

After that you are going to see a new line with active Subscription Status and Handshake:

9 - SAP CPI - Artifact details:

Iflow Steps:

1 - JSON to XML Convert:

      • Because the SAP EM Web-Hook it's HTTPS post call and I need to extract the value from Product and without the next step the content modifier will not works.

2 - Content Modifier - GetProductID:

      • productId - Xpath - java.lang.String

      • Xpath mechanism: //PRODUCT/text()/substring(//PRODUCT,11,16)

      • Why you decide use text and substring xpath functions ?

        • Because to remove the leading zeros from the send message from web-hook

        • SAP EM Sample Data - "PRODUCT":"000000000010120764"

3 -  HTTP call with dynamic configuration:


Iflow image:

You can decide to use HTTP or ODATA, I will present basic of two configurations under the same aspects of the Iflow below:

HTTP Adapter:

Simple configuration of channel - user/pass


ODATA Adapter:

in case that you want download the EDMX from S4HANA to select the entities to generate the query, you just need change the address below or you can download via local file also.:

Add the $metadata - in the end


Select the entities and extensions that you need.

1 - Connect to System:

2 -  Select Entity & Define Operation:

Select Sub Levels because the material descriptions it's under level one - to_description.

11 - Third Party requirement (Only fields that has been change)

This is PoC correct, so image that, the third party just required the change field that has been changed because they somehow don't want update all the time the master data records.

Based on that, the PoC proposal I just changed the description of Material, in this case I just need to forward the entities related with description.

HTTP Adapter:


Odata Adapter:

Just select the entity and extension manually via adapter configuration to produce the correct query call to API as the configuration demonstrated in the picture above.


The web-hook catches a big fish data product description hehehe....


Enchantments for productive scenario:

Add the exception in the SAP CPI Iflow with retry mechanism using JMS or Solace or (SAP EM - similar as Solace) and in case of failed open a incident  a  ServiceNow - you can setup the priority in the JSON or use value mapping table for that.

For that you can use my previous blogs - Get API Blogs SAP "Ricardo Viana":


"Blogs Ricardo Viana":{

Retry Mechanism with Solace and Create Incidente ServiceNow

Retry Mechanism with JMS internal CPI and Create Incidente ServiceNow






The web-hook for callback functionality must be use only for small event messaging.

You must do the analyses together with the business and integration architecture to define the best approach to support your needs - SAP EM event broker support the business with event management process under Web-hook, Restful and Web-socket.

The full setup of SAP EM - Default version - you can take a look in the blogs descriptions, enchantments solutions with retry mechanism in case please check my previous blogs.

SAP Cloud platform integration to compose a full scenario about event read API's from S4HANA on-premise and on-cloud and make your business life easier.

I really hope that you will enjoy, in case of any miss detail or enchantment information let me know.

Kind Regards,


Labels in this area