3

Data Events scenario With SAP Event Enablement Add-on for SAP S/4HANA, SAP Event...

 2 years ago
source link: https://blogs.sap.com/2022/03/04/data-events-scenario-with-sap-event-enablement-add-on-for-sap-s-4hana-sap-event-mesh-and-sap-cloud-integration-step-by-step-guide/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

EM.png

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

Queue

Queue

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

Topic

Topic

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)

RFC-Connection-1.png

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-Connection-Instance-2-1.png

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.

SPRO-Set-Password-2.png

Click Execute.

Secret will be created successfully after execution.

SPRO-Set-Password-3.png

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

Logical-Message-Type-Message-Type.png

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-Message-Type-3-Activate.png

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

Create-Table-View-1.png

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.

Create-Table-View-3-Add-Tables.png

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.

Create-Table-View-Table-Fields-1-1.png

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.

Create-Table-View-Join-Conditions.png

Join Conditions

Save the Table View.

Do Not Forget to activate the table view!!

Create-Table-View-Activate-1.png

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

Create-Outbound-Objects-4-Parameters-1.png

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

Create-Outbound-Objects-5-Header-Attributes-Add.png

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.

Event-Linkage-2-2.png

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>

AMQP-Processing.png

Processing Tab

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

CPI-Groovy-1.png

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.

BP-Created.png

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

CPI-Monitoring-1.png

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK