Skip to Content
Technical Articles
Author's profile photo Benedikt Sprung

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: 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%200%20Navigation%20to%20the%20Business%20Object%20Repository

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%202%20Find%20BUS1001%20in%20SWO1

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%202%20Creating%20a%20subtype%20in%20transaction%20SWO1

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%203%20Create%20your%20new%20Event

Figure 4 Create your new Event

 

Figure%204%20Now%20your%20subtype%20of%20BUS1001%20should%20look%20like%20this

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%205%20Release%20it%20and%20generate%20it%20afterward

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%206%20Create%20the%20linkage%20between%20event%20and%20subtype

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%2007%20Field%20Restrictions%20in%20SWEC

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

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.