Custom Events in SAP Event Mesh. Step-by-Step (Part 1 – Create a Custom Event)
source link: https://blogs.sap.com/2022/03/16/custom-events-in-sap-event-mesh.-step-by-step-part-1-create-a-custom-event/
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.
Custom Events in SAP Event Mesh. Step-by-Step (Part 1 – Create a Custom Event)
Overview
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 SWO1
and SWEC
.
Part 2 (will be added soon): 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”.
Figure 1 Navigate to the 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.
Figure 2 Check the events of BUS1001 in SWO1
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.
Figure 3 Creating a subtype in transaction SWO1
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.
Figure 4 Create your new Event
Figure 5 Now your subtype of BUS1001 should look like this
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 Component -> To released.
Click the generate button.
Figure 6 Release it and generate it afterward
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.
Add your Object Type that you just generated in the previous step and click safe.
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.
Figure 7 Create the Event Linkage for Change Documents
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.
Figure 8 Field Restrictions in SWEC
Conclusion
We extended a subtype of the Business Object BUS1001 by a material change with the following actions:
- Create subtype BO in
SWO1
- Create an event for our subtype in
SWO1
- Link a change document to the BO event in
SWEC
Now we have everything prepared to make use of it in the SAP NetWeaver add-on for event enablement.
In Part 2 (will be added soon) 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 section regarding the SAP Event Mesh.
You can also follow the Tags and Profiles for more upcoming articles.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK