Custom Events in SAP Event Mesh. Step-by-Step (Part 1 – Create a Custom Event)
In this step-by-step guide, we will cover the following:
- How to create a Subtype of a Business Object
- How to create Events for the Business Object
- How to establish the Event Linkage for Change Documents
- Finally, how we can make use of it in our SAP NetWeaver add-on for event enablement
Part 1: We will create a custom Event Linkage for a Material Change using transaction
Part 2: Now we can make use of it in our SAP NetWeaver add-on for event enablement.
Introduction to Part 1
This becomes necessary when the Business Object does not offer the desired event that we want to trigger. A typical example is the change of a material where the “Change Event” is not available by default. Hence, we will proceed with the creation of a subtype that includes the Change Event using the following four steps.
Step 1: Find your Business Object
In our case, we aim to trigger a Material Change, which corresponds to the Business Object BUS1001.
Go to transaction
SWO1–> “Business Object Repository”.
There you will find the Business Object under:
Logistics – General –> Logistics Basic Data –> Material Master –> BUS1001
Double-click on BUS1001 to view the default available events.
As we can see there is no Change Event available by default.
Step 2: Create a subtype of BUS1001
Go to Transaction
SWO1 and create a subtype of BUS1001. Maintain the details as illustrated in the accompanying figure.
Step 3: Create a Change Event
- Click on the “Change” button to review the newly created ZBUS1001 Object. It is now a copy of BUS1001, and we will add our change event here.
- Select and mark “Events” and then click on the “Create” button.
- A popup will appear for your new Material Change Event. Maintain the necessary details in the popup.
Place your cursor on the event and release it:
Edit -> Change Release Status -> Object Type -> To implemented.
Edit -> Change Release Status -> Object Type Component -> To implemented.
Finally, click on the generate button.
Step 4: Event Linkage for Change Documents
Now that we have created our new ZBUS1001 Object Type, the next step is to link it to a change event in the system.
Go to transaction
SWEC New Entries.
Note: We can utilize the Function Module /ASADEV/ACI_CPIDENT_TRANSFER to provide the key of the change document and pass it to the SAP NetWeaver add-on for event enablement. This allows for its usage in data extraction.
Optional Step 5: Field Restrictions
By following the first four steps mentioned above, we have successfully created an Event that will be triggered whenever a change is made to a material.
However, there are cases when we do not want to receive notifications for every single change made to a material. In such cases, we can utilize Field Restrictions to specify the specific events we want to monitor.
This is also done in Transaction
SWEC. Choose the Object Type that we created in Step 4 and click on Field Restrictions. In this example, we are only interested in being notified when a Material Group is changed or when the Material is locked. We will exclude notifications for any other changes made to a material. By implementing these restrictions, we will only receive notifications for the defined events, ensuring we are not overwhelmed by irrelevant notifications.
We have successfully extended a subtype of the Business Object BUS1001 by incorporating a material change through the following actions:
- Create subtype BO in
- Create an event for our subtype in
- Linked a change document to the BO event in
Now that we have completed these steps, we are ready to utilize the SAP NetWeaver add-on for event enablement.
In Part 2 we will ocus on capturing a Material Change and seamlessly transmitting it in real-time to the cloud.
Please provide feedback or thoughts in the comment section.
There is a Q&A regarding the SAP Event Mesh.
You can also follow the tags and profiles for more upcoming articles.