Skip to Content
Technical Articles
Author's profile photo Fiona Zhang

Data Events scenario With SAP Event Enablement Add-on for SAP S/4HANA, SAP Event Mesh and SAP Cloud Integration: Step-by-Step Guide

Last year it was announced that SAP NetWeaver Add-On for Event enablement is also available for SAP S/4HANA in this blog post. Thanks to that customers can build customized events in SAP S/4HANA systems. There are also blog posts with step-by-step guides on how to create notification events with customized message types in SAP ECC:

However, data events are always the area that customers would like to understand more because in some cases the publisher of the events want to decouple entirely in the communications and are not expecting additional API calls for more information after events have been delivered.

Syed Ejazuddin has already published a blog post on data events. But in this blog post, I will show you the end-to-end configuration in both SAP S/4HANA and SAP Event Mesh. To make the scenario closer to a real use case, I’m using SAP Cloud Integration of SAP Integration Suite as a consumer for the data events triggered.

 

 

Data Events vs. Notification Events

Both data events and notification events inform consumers of significant changes.

However, Notification events are typically as small as possible and contain only the absolutely required information. The idea behind this type of event is that consumers are informed of a change and can then decide whether they care about this change or not. If the change isn’t relevant for the consumer, the consumer ignores the event completely. If the change is relevant for the consumer, the consumer will follow up by requesting additional data and executing on this data.

On the contrast, data events already contain all data in respect to the event that might be relevant for the consumer. No additional request is needed. other advantage/difference is, with SAP Event Enablement Add-on, you can build table views to extract data from multiple database tables.

In this blog post, I will introduce you the step-by-step guide on how to build data events With SAP Event Enablement Add-on for SAP S/4HANA and SAP Event Mesh, and consume the events with SAP Cloud Integration AMQP adapter.

Prerequisites

  1. SAP Event Mesh (default plan) has been provisioned in your subaccount.
  2. User has been granted the necessary role collections on SAP BTP
  3. Service Instance, Service Key, Message Queue are ready
  4. Installation of the Add-on. Installation and Set-Up Documentation can be found at: https://help.sap.com/viewer/e966e6c0e61443ebaa0270a4bae4b363/1.0/enUS/3eba827c531344eb879d8e35022d90ba.html

 

Step 0: Queue and Topic creation in SAP Event Mesh

Before all the configuration and testing, the Queue and Topic in SAP Event Mesh should be ready. I’ll not put the detailed steps here as this has been described in a lot of other blog posts and tutorials.

The Queue name I used in this guide is: SAP/EM/DEMO/BP/DataEventsQ

The Topic name I used in this guide is: SAP/EM/DEMO/BP/DataEventsT

Step 1: Configure HTTP Connections in SAP S/4HANA

1.1 Create a RFC connection

Go to SM59 –> Create RFC Connection with connection type ‘G’ –> pointing to the URI from the service key (from the httprest section)

Service%20Key

Service Key

 

Enter the URI in the “Host” without “https://” from the service Key:

RFC%20Connection%20Type%20G

RFC Connection Type G

1.2 Create an OAuth Connectivity

Create another RFC connection with Type “G” with the token endpoint from the service key

Create%20OAuth%20Connection

Create OAuth Connection

Enter the token endpoint from the service key and enter “/oauth/token” in the Path Prefix

Enter%20Token%20Endpoint

Enter Token Endpoint

In “Logon and Security” tab, select “active” and “Anonym ssl client (Anonym)” for Security Option

Logon%20and%20Security

Logon and Security

 

Step 2: Configuration in SAP S/4HANA SPRO –> SAP Reference IMG

2.1 Create a new connection instance

Go to transaction SPRO –> SAP Reference IMG –> Integration with other SAP Components –> SAP NetWeaver AddOn for Event enablement –> Connection and Replication Object Customizing

Connection%20and%20Replication%20Object%20Customizing

Connection and Replication Object Customizing

Click “New Entries” to create a new connection instance

New%20Entries

New Entries

Enter a descriptive Instance name, in my case it’s EM_EDMO_INS.

Enter the RFC HTTP Destination that was created in step 1.1, put the ISO code to utf-8 and select Cloud Type as “SAP EM” which is the type for SAP event mesh communication for Event enablement.

Create an Instance

Go to “Default Values”, add SAP_EM_CLIENT_ID default attributes and enter Client ID from Service Key. Add another default attribute with name SAP_EM_TOKEN_DESTINATION, and enter the OAuth Connection name that was created in Step 1.2.

Default%20Values

Default Values

 

Go to “Error Type Mapping” and create mapping for different response codes to ensure correct handling of the codes.

Error%20Type%20Mapping

Error Type Mapping

Save the changes.

2.2 Set Cloud Connection Password for the connection created

Go to transaction SPRO –> SAP Reference IMG –> Integration with other SAP Components –> SAP NetWeaver AddOn for Event enablement –> Set the cloud connection password

Set%20the%20cloud%20connection%20password

Set the cloud connection password

Select the Cloud Instance that was created and enter the password with the client secret from the Service Key.

Click Execute.

Secret will be created successfully after execution.

2.3 Create Logical message type for the event communication

Create message type: Go to transaction SPRO –> SAP Reference IMG –> Integration with other SAP Components –> SAP NetWeaver AddOn for Event enablement –> ALE Delta Customizing –> Message Type in ALE for Cloud Interface — Click “New Entries”

Message%20Type%20in%20ALE%20for%20Cloud%20Interface

Message Type in ALE for Cloud Interface

New%20Entries

New Entries

For our example I create the message type ZBP_Data

Message Type

 

Save the Message Type.

 

Activate message type: Go to transaction SPRO –> SAP Reference IMG –> Integration with other SAP Components –> SAP NetWeaver AddOn for Event enablement –> ALE Delta Customizing –> Activate Change Pointers for Message Types — Click “New Entries”

Activate%20Change%20Pointers%20for%20Message%20Types

Activate Change Pointers for Message Types

New%20Entries

New Entries

Select the message type that was created – ZBP_Data, select “active” and Save the data.

Activate the message type

Step 3: Build Database table view for all the data needed from Business Partner tables

Go to Transaction SE11–>Enter a Database view name, in our case I entered ZBUSINESSPARTNER –>Click Create

 

 

Select%20Database%20view

Select Database view

In Table/Join Conditions tab, select all the tables you want to extract data from which are related to Business Partner, in this example I selected BUT000 and BUT020.

Add tables

In View Fields Tab, click Table Fields –> Select the table you want to add fields from and click Copy –> Repeat for all the tables, make sure there are no duplicated fields. Select all the fields that are required for data extraction.

Table Fields

 

Go back to Table/Join Conditions tab and select the tables to create join conditions, make sure the join conditions are as simple as possible.

Join Conditions

Save the Table View.

Do Not Forget to activate the table view!!

Activate the Table View

Step 4: Customize Outbound Object

4.1 Create an outbound object

After creating your own message type for communication, you need to create your Outbound Object and link the logical message type.

Go back to transaction SPRO –> SAP Reference IMG –> Integration with other SAP Components –> SAP NetWeaver AddOn for Event enablement –> Connection and Replication Object Customizing

Connection%20and%20Replication%20Object%20Customizition

Connection and Replication Object Customizing

Select the Connection Instance created earlier in step 2.1. In our case the name is EM_DEMO_INS

EM_DEMO_INS

EM_DEMO_INS

Click “Outbound Objects”

Outbound%20Objects

Outbound Objects

Change to Edit mode and click “New Entries”

New%20Entries

New Entries

 

  • Put a descriptive name for the outbound object, in my case, I put EM_DEMO_BP
  • Enter the Extraction Function Module as /ASADEV/ACI_GEN_VIEW_EXTRACTOR
  • Enter Item Lines as 1
  • Enter the Message Type created in step 2.3, in our case, it’s ZBP_Data
  • Select a Load Type, in this case I use Incremental Load
  • Select “SAP EM” as Implementation Event
  • Enter the Formatting Function as /ASADEV/ACI_GEN_VIEWFRM_SAP_EM

4.2 Enter the Header Attributes for the outbound object

Click Header Attributes and click New Entries.

Enter below header attributes:

  • ACI_VIEW – name of the database table view created in step 3 (this is very important for data events as all the customizations for the data come from this table view). In our case, it’s ZBUSINESSPARTNER
  • SAP_EM_CALL_METHOD – “POST”
  • SAP_EM_CONT_TYPE – “application/json”
  • SAP_EM_QOS – Can be “0” or “1” depending on the quality of service you want to use, in my case I use 1
  • SAP_EM_TOPIC – The topic name you created in SAP Event Mesh, in our case, it’s SAP/EM/DEMO/BP/DataEventsT

Header Attributes

Save the data.

 

4.3 Create Event Linkage

Go to transaction SWE2 and create event linkage for the data event:

Create%20Event%20Linkage

Create Event Linkage

 

In the detailed page, add the BP object type and put the event, here I put CREATED. And link it to the receiver type that was created in the logical message type – ZBP_DATA.

The receiver Function Module to trigger the event is /ASADEV/ACI_EVENTS_TRIGGER (this is the FM starting from SP02 of the add-on).

Activate the linkage.

Step 5: Create an iFlow in SAP Cloud Integration

3.1 Create an iFlow with the default template and use AMQP sender adapter

Create an iFlow and select AMQP adapter as sender adapter.

iFlow%20in%20SAP%20Cloud%20Integration

iFlow in SAP Cloud Integration

 

In the Connection Tab, enter below parameters:

  • Host: the amqp uri of the SAP Event Mesh service in the Service Key
  • Port: 443
  • Path: AMQP path in the Service Key, which is /protocols/amqp10ws
  • Proxy Type: Internet
  • Authentication: OAuth Client Credentials artifact created in security material with the token endpoint, client ID and client secret from the Service Key
  • Credential Name: The name of the OAuth Credential

Connection%20Tab

Connection Tab

OAuth%20Credential%20in%20Security%20Material

OAuth Credential in Security Material

In the Processing Tab, enter the queue name with format: queue:<queue name>

Processing Tab

Add a groovy script to log the payload in attachment so that it can be easily viewed for testing purpose.

Groovy%20-%20Log%20the%20payload

Groovy – Log the payload

 

Deploy the iFlow in SAP Cloud Integration.

Step 6: Testing

Go to Transaction BP, create a new Business Partner and save the data.

Go to SAP Cloud Integration Message Monitoring and check the message.

The payload has been logged in the attachment. You can find all the details for the related to the BP created.

Payload%20in%20SAP%20Cloud%20Integration

Payload in SAP Cloud Integration

Payload%20in%20JSON%20format

Payload in JSON format

 

Summary

With this step-by-step guide, you should be able to build a scenario with either SAP S/4HANA system or SAP ERP system together with this SAP Event Enablement Add-on. The benefit of this Add-on is that you can customize your own events on top of the standard objects. And with SAP Event Broker as a service – SAP Event Mesh, it will be easy to connect to event-enabled SAP backends. Hope you find all the above steps easy to implement. Happy Eventing!!!

 

Additional Info

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Syed Ejazuddin
      Syed Ejazuddin

      Hi Fiona,

      Thanks for the mention Fiona Zhang. Really Cool blogs!.

      I would also like to mention that we have dedicated mission for Addon in SAP Discovery Centre so that community can try out as well.

      Author's profile photo Fiona Zhang
      Fiona Zhang
      Blog Post Author

      Hi Syed,

       

      Thanks for your comment. And I would also thank you so much for answering all my questions on data events.

      I didn't realize there was a mission published for this. Thanks for the notice. I just checked the mission video and it's a very complete scenario. I'll definitely recommend everyone to try out. Hope my blog post will help those who are not familiar with the detailed steps on triggering data events from SAP S/4HANA.

       

      Thanks,

      Fiona

      Author's profile photo Bodhisattwa Pal
      Bodhisattwa Pal

      Hello Fiona Zhang Syed Ejazuddin

      Thanks for uploading the blog .We were actually setting up the event add on enablement .

      Just wanted to check if this is a feature in Event Add on enablement  .

      Can we trigger the message type (in turn the message type triggers the Event) only when certain fields of the Business Object change ..

      Example :-  Sales Order .

      The event should trigger only when the PO reference field in a Sales Order  changes .

       

      Author's profile photo Benedikt Sprung
      Benedikt Sprung

      Hello Bodhisattwa Pal,

      this can be configured in transaction SWEC --> Field Restricitions

      There is a tutorial in this blog post.

      Kind regards

      Benedikt

      Author's profile photo ebsor ---
      ebsor ---

      Hi Fiona,

      Thanks for such nice article and all the steps, I have followed all the steps but queue is not being populated when I create Business Partner.

      How to troubleshoot from s4 side to know where error is? how can I break it for troubleshooting?

      thanks

      ebsor

      Author's profile photo Tobias Griebe
      Tobias Griebe

      Hi ebsor ---,

      for troubleshooting options you can have a look at: Enterprise Event Enablement: Troubleshooting

      Depending on the version of your S/4 system (Cloud or on-prem and the respective version), you should first try to identify if the event was even sent out. If this was successful, next step is to look into your queue subscriptions. I would start with the most generic one (e.g. <your>/<s4>/<namespace>/* ) to avoid any typos/mistakes.

      Best regards,
      Tobias

      Author's profile photo Fiona Zhang
      Fiona Zhang
      Blog Post Author

      Hi Tobias,

       

      Thanks for your response here. However I think the blog post you mentioned is for Enterprise Event Enablement not for the Event Enablement Add-on which is the focus in this blog, right?

      But thank you for trying to help here. The blog post you have is very useful for Enterprise Event Enablement Framework indeed.

       

      Thanks,

      Fiona

      Author's profile photo Fiona Zhang
      Fiona Zhang
      Blog Post Author

      Hi ebsor,

       

      For troubleshooting on the event-enablement add-on, you can first use transaction /asadev/aci_monitor to check if there are any entries. You can also check SLG1 for the application log.

       

      Thanks,

      Fiona

      Author's profile photo ebsor ---
      ebsor ---

      Hi Fiona,

       

      I have created one BP but I can see nothing in /asadev/aci_monitor & SLG1. I am not sure what has gone wrong here.

       

      Any hints which might help?

       

      One more question from your previous answer to Tobias is Event Enablement Add-on free add on and whats the difference between this and Enterprise Event Enablement?

       

      thanks and regards,

       

      ebsor--

      Author's profile photo Jyotika Manghani
      Jyotika Manghani

      Hi Fiona,

      Thank you for the very insightful blog!

      We have a similar requirement for Product Master. For materials, if we create a database view, for MARA, MVKE & MAKT, the view can contain multiple data records for a single material.

      How would the extractor framework behave in such a case?

      Kindly advise.

      Thanks,

      Jyotika.

       

      Author's profile photo Jeet Jassi
      Jeet Jassi

      Hello Fiona Zhang Tobias Griebe

      We followed the steps here in order setup connection between S/4HANA 2021 & Event Mesh (Default Plan) using Event Enablement AddOn, however even after verifying all the steps, Data Events are not getting generated during creation of BP. (BTW: We also tried with Notify Events setup using Add-On enablement, this also didn´t generate any events)

      Hence, I would like to check with you the following:

      1. Do we need to also run SWU3 to setup S/4HANA automatic workflow customizing?
      2. Is it necessary to have entries in BDCP2 table post creation of BP?? This is currently not automatically updated in our case. Could you please also suggest how to have this configured.

      If one or both steps above are also pre-requisite of triggering events seamlessly from S/4HANA to Event Mesh using EEA component?

      Looking forward to your response.

      Author's profile photo SOUMEN DAS
      SOUMEN DAS

      Is it possible to connect S4 events with EMH KAFKA as well or is this exclusive only for SAP BTP Event mesh only?