Creating Events 

Objects can indicate that their state has changed by triggering a method. You can define events in both classes and interfaces, which you can then trigger from within a method using the RAISE EVENT statement. Each class (or interface) that is going to handle the corresponding event must implement a relevant handler method, and register it using the SET HANDLER statement. When an event occurs, the system calls all of the handler methods registered for that event.

Like method definitions, events have a parameter interface. The only difference is that events may only have EXPORTING parameters.

Prerequisites

You must already have created the class or interface.

The following description assumes that you are familiar with the principles of ABAP Objects.

Procedure

  1. Start the Class Editor in change mode.
  2. Choose Events.
  3. Enter the following information:

    - Event
    A unique name to identify the event.

    - Type
    Specifies the event as an instance event or a static event.

    -Visibility
    Defines the visibility of the events as public, protected, or private.

    - Modeled
    If you select this option, the system does not enter the event in the class pool. You will not be able to access the component at runtime.

    - Description
    Short description of the event.
  4. Repeat steps 1 - 3 for any further events.

  5. Save your entries.

 

Result

You have now created events for your object type. The events are listed in the declaration part of the class or interface after the EVENTS statement.

You can specify events further by giving them EXPORTING parameters. For the procedure, refer to Creating parameters and exceptions and Implementing methods.

For further information about event handling within ABAP Objects, refer to the syntax documentation in the ABAP Editor (for example, for the RAISE EVENT statement).