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.
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
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
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
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.
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!!
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:
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.
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.
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!!!