Custom Events in SAP Event Mesh. Step-by-Step (Part 1 – Create a Custom Event)
In this step-by-step guide, we will see:
- 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
In this Blog Post we will see, how to create a custom event. This is necessary if the Business Object does not provide us with the event, that we want to be able to trigger. A common example is a change of a material. The “Change Event” is not provided by default. Therefore, we will create a subtype including the Change Event using the following 4 steps.
Step 1: Find your Business Object
In our case, we want to be able to trigger a Material Change, which is the Business Object BUS1001.
Go to transaction
SWO1–> “Business Object Repository”.
There you will be able to find the Business Object under:
Logistics – General –> Logistics Basic Data –> Material Master –> BUS1001
Doublecklick BUS1001 in order to see the events that are available by default.
As we can see that 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 shown in Figure 3.
Step 3: Create a Change Event
Now we can click on the “Change” button to have a look at our newly created ZBUS1001 Object. It is now a copy of BUS1001 and we will add our change event here.
Mark “Events” and click “Create”. Maintain popup for your new Material Change Event.
Place your curser on the event and release it:
Edit -> Change Release Status -> Object Type -> To implemented.
Edit -> Change Release Status -> Object Type Component -> To implemented. Edit -> Change Release Status -> Object Type -> To released.
Edit -> Change Release Status -> Object Type Component -> To released.
Click the generate button.
Step 4: Event Linkage for Change Documents
Now that we created our new ZBUS1001 Object Type, we want to link it to a change event in the System.
Go to transaction
SWEC New Entries.
Note: With the Function Module /ASADEV/ACI_CPIDENT_TRANSFER we can provide the key of the change document and pass it to the SAP Netweaver Add-on for event enablement to be used in the data extraction.
Optional Step 5: Field Restrictions
By following the first 4 steps above we created an Event that will be triggered with any change that is being done on a material.
Sometimes we don’t want to get notified of every change that is happening on a Material. Therefore, we can use Field Restrictions and specify the Events that we want to be able to see.
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 to be notified, when a Material Group is changed or the Material gets locked. Now we don’t get notified by any other Change on a Material. See the configurations in Figure 8.
We extended a subtype of the Business Object BUS1001 by a material change with the following actions:
- Create subtype BO in
- Create an event for our subtype in
- Link a change document to the BO event in
Now we have everything prepared to make use of it in the SAP NetWeaver add-on for event enablement.
In Part 2 we will catch a Material Change and push it in real-time into 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.