Home Back

SAP BTP Event Mesh — from S4 to SCI

sap.com 1 day ago

SAP BTP Event Mesh is a service that allows applications to communicate through asynchronous events. It supports a plethora of SAP standard events from BOR objects and classes (on S/4HANA systems). However, if you need custom events or events from older R/3 systems, you must install the ASAPIO Integration Add-on.

Our recent side-by-side extension solutions are all implemented using EDA (Event-Driven Architecture), which, in the SAP BTP portfolio, is supported by Event Mesh. SAP BTP Cloud Integrations serve as an enterprise integration platform, usually acting as a central communication hub that also has access to on-premise systems within a corporate network.

This blog post integrates all these services and components into one solution, providing a method to relay information about an event from on-premise SAP to the SCI (SAP Cloud Integration) and beyond (e.g., SAP BUILD, Fiori Applications, third-party apps, etc.).

vbalkoclaimate_0-1719245740525.png

Prerequisities

Event Mesh Instance on BTP

Create instance on BTP

Add json configuration — I use template below, where

  • <ns1> — usually name of organization (eg. nike)
  • <ns2> — something to distinguis processes (eg. procurement)
  • <ns3> — distinguisher of landscape level (eg. S4Dev, S4Test, S4Prod)
  • <name> is identified, which will be shown in Event Mesh Saas application, as message client
vbalkoclaimate_2-1719245740502.png
{
"options": {
"management": true,
"messagingrest": true,
"messaging": true
},
"namespace": "<ns1>/<ns2>/<ns3>",
"rules": {
"topicRules": {
"publishFilter": [
"${namespace}/*"
],
"subscribeFilter": [
"${namespace}/*"
]
},
"queueRules": {
"publishFilter": [
"${namespace}/*"
],
"subscribeFilter": [
"${namespace}/*"
]
}
},
"version": "1.1.0",
"emname": "<name>"
}

Note: namespace creation is just my personal best practice — you can create your own one

Create service key for that instance and download it. We will need it in next step.

vbalkoclaimate_3-1719245740610.png

Configuration in SAP

Creation of destinations

We will start by creating connection from on premise SAP to the SAP BTP Event Mesh instance.

Go to the SE38 and run report ASADEV/ACI_EM_RFC_CREATE.

This record will create two necessary destination for you automatically, just add Cloud Instance name, RFC Name and load your downloaded json from service key.

As an Cloud Instance Name, you should put name of your BTP EM instance (you can make some up).

vbalkoclaimate_4-1719245740505.png

Also dont forget to add endpoint certificate to the STRUST. Endpoint can be found in service key under http protocol uri

vbalkoclaimate_5-1719245740357.png

Execute, and you should see message showing success

Now you can check created destinations in SM59. Look into G category.

Configuration of outbound message

In SPRO tcode go to Integration with Other SAP Components/SAP NetWeaver AddOn for Event Enablement/Connection and Replication Object Customizing

vbalkoclaimate_8-1719245740406.png

There you can find almost all configuration — so choose your newly created Instance and add destinations + ISO Code and Cloud Type.

Note: If you dont have ISO Code and Cloud Type configured, you can do it in spro (1) and (2)

vbalkoclaimate_10-1719245740441.png

Next, you should check/maintain default values for connection.

vbalkoclaimate_11-1719245740438.png

And also maintain error type mappings

vbalkoclaimate_12-1719245740440.png

Now to the core of our topic — add outbound type details

I will use USER object as an example

vbalkoclaimate_14-1719245740568.png

Maintain:

  1. Extraction function module as /ASADEV/ACI_SIMPLE_NOTIFY
  2. Message Type as existing or your custom message type (depends on your requirements). You can maintain message types in WE81 — and dont forget to activate change pointer for it
  3. Event as SAP_EM
  4. Check trace, so you can find it in monitoring (/n/ASADEV/ACI_MONITOR)
  5. Format Function as /ASADEV/ACI_SAP_EM_CLOUDEV_FM
vbalkoclaimate_15-1719245740375.png

Note: There are many more function modules to configure here, but they are out of scope of this blog

Now for your outbound object, maintain event linkage

Add:

  • category of object as BOR Object
  • type of objects as ID of your BOR Object
  • Event name
  • function module name as /ASADEV/ACI_EVENTS_TRIGGER
  • and dont forget to check object linkage active

Header Attributes should be added as

  • SAP_EM_CALL_METHOD: POST
  • SAP_EM_CONT_TYPE: application/json
  • SAP_EM_QOS: 0
  • SAP_EM_TOPIC: <ns1>/<ns2>/<ns3>/<object>/<topicName>
vbalkoclaimate_17-1719245740414.png

This should be all, what we need to configure in an on premise system.

Configuration in Event Mesh application

Creating of Queue

Select you event mesh client and create new QUEUE

vbalkoclaimate_18-1719245740606.png

Now, when you have queue created, you need to subscribe this queue to the topic

Copy name of the topic, you maintained in SAP Header attributes and put it as topic name (1) then push button Add (2) and you should see added topic in list of subscribed topics (3)

vbalkoclaimate_20-1719245740456.png

Note: Now you should be able to test if you will be able to receive event in BTP Event mesh. Just trigger that event in SAP and refresh queue. You should see new message.

Creating of Webhook

Now we will create and configure webhook, which will propagate that event from SAP BTP EM to the SAP SCI (Cloud Integration). We should have iFlow in SCI, with HTTP sender adapter. Copy endpoint URL of that http adapter, and also get credentials from SCI instance service key in order to authenticate with webhook towards SCI.

In Event Mesh go to the Webhooks tab and push Create Webhook Button.

Maintain:

  • Subscription name — you can create your own
  • select your desired topic — this should be topic from which you want to propagate events to SCI
  • QoS as 0
  • Exempt handshake as YES
  • On Premise as no, because we are sending event to the cloud service
  • Webhook URL from the SCI iFlow
  • Content-type as application/json
  • Authentication as OAuth2ClientCredentials and also insert client id, client secret and token url from service key of SCI Instance

Newly created webhook is paused, so you must trigger handshake to initiate connection

Confirm dialog

and webhook should be active

Now you should be able to receive event from the backend SAP system up to the SCI as a http message.

Disclaimer: I have posted this blog post also on my personal blog https://medium.com/@vbalko/sap-btp-event-mesh-from-s4-to-sci-47d1a273739c

People are also reading