CLAIMATE

Technical blog

SAP BTP Event Mesh — from S4 to SCI

created by DALL-E

Vlado Balko

24. 8. 2024

Integration

Introduction

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

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

{
  "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.

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

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

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

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)

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

And also maintain error type mappings

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

I will use USER object as an example

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

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>

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

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)

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.

It was also published here:

https://community.sap.com/t5/technology-blogs-by-members/sap-btp-event-mesh-from-s4-to-sci/ba-p/13741285
https://medium.com/p/47d1a273739c

Navigace

© 2023 CLAIMATE

Navigace

© 2023 CLAIMATE