Skip to Content
Technical Articles
Author's profile photo Ketan Sood

Custom Event generation through change documents and handling with Abap class

Business Scenario

While changing the material variant configuration , some other changes have to be performed in the Material.  Change of Material variant config is saved in the table CDHDR with the Objectclass IBINVALUES .


Following steps needs to be carried out in order to generate and handle the change event of the Object IBINVALUES.

Create Class and Event

Create a class and event , which has to be triggered when the variant configuration is changed.

Mapping object class to Event in SWEC

In this case , two entries have been created , for creation and change event .

While creating these Entries , there comes some waring regarding the Namespace, which can be ignored. Also an error will come that the interface IF_WORKFLOW is not implemented in the class. So you need to implement this Interface in your Event class. This Interface includes some other Interfaces which will be automatically added.

Create method to handle the event 

Now in order to handle the event , handler method has to be created. This Handler method comes with the Interface BI_EVENT_HANDLER_STATIC . Same class which is containing the Event could also be used for creating the handler method . This method contains various Importing parameters out of which the Event and Event_container are the most Important ones.


Through the following code , obect id present in the table CDHDR could be read.

 CASE event.
*    Read Object id from container . Event container object is available as object reference .
            CALL METHOD event_container->get
                name       = 'CD_OBJECTID'
                value      = lf_object_id
                returncode = lf_returncode.

          CATCH cx_swf_cnt_cont_access_denied


Assigning Handler method to the Event through SWETYPV

The custom event will be raised and the method to handle the event is also available. With the following linkage , the Event handler is assigned to the event.


Activate the tracing in SWELS and see the event generated and forwarded to the method in the tcode SWEL.



Following these steps, it will be possible to Implement actions on any change object class.

Let me know if there are any questions or comment if anything related to this topic is important .

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Twerenbold
      Daniel Twerenbold

      Dear Ketan

      Thank you for this blog. Very clearly understandable!