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:
- SAP Enterprise Messaging for SAP ERP: HowTo-Guide (Part 1 – Connectivity)
- SAP Enterprise Messaging for SAP ERP: HowTo-Guide (Part 2 – First use case)
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.
- SAP Event Mesh (default plan) has been provisioned in your subaccount.
- User has been granted the necessary role collections on SAP BTP
- Service Instance, Service Key, Message Queue are ready
- 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)
Enter the URI in the “Host” without “https://” from the service Key:
1.2 Create an OAuth Connectivity
Create another RFC connection with Type “G” with the token endpoint from the service key
Enter the token endpoint from the service key and enter “/oauth/token” in the Path Prefix
In “Logon and Security” tab, select “active” and “Anonym ssl client (Anonym)” for Security Option
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
Click “New Entries” to create a new connection instance
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.
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.
Go to “Error Type Mapping” and create mapping for different response codes to ensure correct handling of the codes.
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
Select the Cloud Instance that was created and enter the password with the client secret from the Service Key.
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”
For our example I create the message type ZBP_Data
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”
Select the message type that was created – ZBP_Data, select “active” and Save the data.
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
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.
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.
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.
Save the Table View.
Do Not Forget to 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
Select the Connection Instance created earlier in step 2.1. In our case the name is EM_DEMO_INS
Click “Outbound Objects”
Change to Edit mode and click “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
Save the data.
4.3 Create Event Linkage
Go to transaction SWE2 and create event linkage for the data event:
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.
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
In the Processing Tab, enter the queue name with format: queue:<queue name>
Add a groovy script to log the payload in attachment so that it can be easily viewed for testing purpose.
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.
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!!!
- You can ask questions about the topic in SAP Community with the Q&A tag link for SAP Event Mesh
- SAP Community topic for SAP Event Mesh: https://community.sap.com/topics/event-mesh.
- SAP Help Guide on SAP NetWeaver Add-On for Event enablement
- SAP Help Guide on SAP Event Mesh
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.
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.
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 .
Hello Bodhisattwa Pal,
this can be configured in transaction SWEC --> Field Restricitions
There is a tutorial in this blog post.
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?
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.
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.
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.
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,
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?
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:
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.
Is it possible to connect S4 events with EMH KAFKA as well or is this exclusive only for SAP BTP Event mesh only?
Thanks for this very informative blog!
When I create the BP I do not get any errors.
However, I am getting the error: "Nothing uploaded: Cloud type not selected." in /ASADEV/ACI_MONITOR.
Can you please advice if you have any insights into this?
Please make sure that the BC sets with the addon configuration are activated as documented HERE.
After activating the BC sets, make sure to transport all the table entries as described HERE.
Hope this helps.
Does this technique also work for the s/4hana cloud? If not, what is the equivalent technique in the s/4hana cloud?
I believe this blog is for S/4HANA on-prem only, S/4HANA Cloud allows outbound notification events in CloudEvents format. You will find it in "Enterprise Event Enablement" on your S/4HANA Cloud system; once you enable it, you will select your topic (for example, Business Partner), and it will send it to Event Mesh in BTP.
if you want to get started with Event-driven architectures with the S/4HANA Cloud there is an excellent concept in the SAP Discovery Center called Missions.
Also, a recommended read is the newly released SAP Press Book - Business Technology Platform
Also, check out these blogs by Tobias Griebe and Makoto Sugishita
Hi Ly-Na Phu,
there is also an additional approach for the S/4HANA Cloud using RAP that has been introduced in 2022s TechEd.
Please check Siddhartha Routh's and Safa Golrokh Bahoosh's blog entries below:
Thanks, Mario De Felipe and Tobias Griebe, for the quick and valuable information to read.
What I have seen so far is that we can push the event only to the SAP BTP Event Mesh. What about pushing the event to third-party external event providers or buses such as Kafka, Pulsar, or Salesforce Event Bus. In this case, we are looking for a simple way like webhook support in the BTP Event Mesh. Here we just need to provide a webhook URL (HTTP protocol and not MQTT, ..) to push the data to the endpoint. Is such a simple webhook URL possible to use?
Appreciate you nice blog.
I can see that there is default filter functionality for outbound event based on BO`s fields.
Besides this standard functionality, is there any way which we can make some customized codes to enhance filter functionality?
Thanks a lot.
I have applied your method but I am stucked in groovy script part as it is not taking the fromat you have provided.
Thanks & Regards