Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
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.

ejaz123 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/3eba827c531344eb879d8e35022d90...


 

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 Key


 

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


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 OAuth Connection


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


Enter Token Endpoint


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


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 and Replication Object Customizing


Click "New Entries" to create a new connection instance


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 Values


 

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


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 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 Type in ALE for Cloud Interface



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 Change Pointers for Message Types



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


Click "Outbound Objects"


Outbound Objects


Change to Edit mode and click "New Entries"


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 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 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 Tab



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 - 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 in SAP Cloud Integration



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


22 Comments
syed12
Advisor
Advisor
0 Kudos
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.
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
BODHISATTWA__20
Participant
0 Kudos

Hello fiona_zhang ejaz123

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 .

 

bins2
Participant
0 Kudos
Hello Bodhisattwa Pal,

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

There is a tutorial in this blog post.

Kind regards

Benedikt
ebsor
Participant
0 Kudos

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

Tobias_Griebe
Advisor
Advisor
0 Kudos
Hi zubair.aslam,

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
0 Kudos
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
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
ebsor
Participant
0 Kudos

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

jmanghan
Discoverer
0 Kudos
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.

 
Jitendra_Jeswan
Contributor
0 Kudos

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.

0 Kudos

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

kshitijak
Member
0 Kudos
Hi Fiona,

 

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?

 

Thanks,

Kshitija
lynap
Explorer
0 Kudos
Dear friends,

Does this technique also work for the s/4hana cloud? If not, what is the equivalent technique in the s/4hana cloud?

Thanks,

Ly-Na
MarioDeFelipe
Contributor
0 Kudos

Hi Ly-Na

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

https://blogs.sap.com/2020/08/27/enterprise-event-enablement-troubleshooting/

https://blogs.sap.com/2020/07/01/how-to-use-sap-s-4hana-event-enablement-with-sap-cloud-platform-en/

Tobias_Griebe
Advisor
Advisor
0 Kudos
Hi lynap,

there is also an additional approach for the S/4HANA Cloud using RAP that has been introduced in 2022s TechEd.

Please check siddhartha_routh and safa_bahoosh blog entries below:

https://blogs.sap.com/2022/09/08/rap-based-events-in-sap-s-4hana-cloud-abap-environment-aka-embedded...

https://blogs.sap.com/2022/09/19/how-to-create-rap-business-events-in-sap-btp-abap-environment/

Best regards,
Tobias
lynap
Explorer
0 Kudos
Thanks, mario.defelipe4  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?

Regards,

Ly-Na
lukasz_grochal
Participant
0 Kudos
Hi Kshitija,

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.

Lukasz
LouisHuang
Advisor
Advisor
0 Kudos
Hi. Fiona.

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.
singhsahab811
Explorer
0 Kudos
hey,

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


vincent_pilotte
Discoverer
0 Kudos
The right extension for Javascript is .js - not .java

The script in the blog post above is Groovy Script so it is .groovy or .gsh
Miku
Explorer
0 Kudos
Hi,'

 

Thanks for the detailed information. Notification event is sending the data properly with purchase order number (when /ASADEV/ACI_SIMPLE_NOTIFY and /ASADEV/ACI_SAP_EM_CLOUDEV_FM are used in "Outbound Objects" in SPRO)

but data event is not able extract any data (when /ASADEV/ACI_GEN_VIEW_EXTRACTOR and /ASADEV/ACI_GEN_VIEWFRM_SAP_EM are used in "Outbound Objects" in SPRO).

Please suggest what could be the issue.

In SLG1 and /ASADEV/ACI_MONITOR, I can see that it is showing as no content for data event (where as notification event is ok)


SLG1 logs showing no content for data event


 


Notification Event has 286 bytes but Data Event has 0 bytes


 

Thanks,

Chanchal