cancel
Showing results for 
Search instead for 
Did you mean: 

Event handler method

sushant_singh
Participant
0 Kudos

Hi all,

I want to know the significance of creating event handler method in Class builder.

and how it can be used at the time of event trigger.( Is it called automatically or programmer need to call it explicitly in the program.)

Thanks,

Sushant singh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Event Handler is invoked on an

Event of the developer or the end user where as a method you need to invoke in your code. You need to call the method explicitly.

Regards,

Omkar.

Answers (2)

Answers (2)

Former Member
0 Kudos

hI,

GIVE UR MAIL ID I WILL SEND U AN EXAMPLE WITH SCREEN SHOTS.

WITH THAT U CAN UNDERSTAND.

rgds,

bharat.

sushant_singh
Participant
0 Kudos

hi Bharat ,

my email id is : sushant.singh@vikalpsolutions.com

Thanks for the response.

Former Member
0 Kudos

Hi Sushant,

1. In ABAP Objects, triggering and handling an event means that certain methods act as triggers and trigger events, to which other methods - the handlers - react. This means that the handler methods are executed when the event occurs.

2.To trigger an event, a class must

Declare the event in its declaration part

Trigger the event in one of its methods

3.You declare events in the declaration part of a class or in an interface. To declare instance events, use the following statement:

EVENTS evt EXPORTING... VALUE(e1 e2 ...) TYPE type [OPTIONAL]..

4. An instance event in a class can be triggered by any instance method in the class. Static events can be triggered by any method. However, static methods can only trigger static events. To trigger an event in a method, use the following statement:

RAISE EVENT evt EXPORTING e1 = f1 e2 = f2 ...

5. Events are handled using special methods. To handle an event, a method must

be defined as an event handler method for that event

be registered at runtime for the event.

Declaring Event Handler Methods

Any class can contain event handler methods for events from other classes. You can, of course, also define event handler methods in the same class as the event itself. To declare an event handler method, use the following statement:

METHODS meth FOR EVENT evt OF cif IMPORTING e1 e2 ...

6. Registering Event Handler Methods

To allow an event handler method to react to an event, you must determine at runtime the trigger to which it is to react. You can do this with the following statement:

SET HANDLER h1 h2 ... [FOR]...

It links a list of handler methods with corresponding trigger methods. There are four different types of event.

7. Timing of Event Handling

After the RAISE EVENTstatement, all registered handler methods are executed before the next statement is processed (synchronous event handling). If a handler method itself triggers events, its handler methods are executed before the original handler method continues. To avoid the possibility of endless recursion, events may currently only be nested 64 deep.

Handler methods are executed in the order in which they were registered. Since event handlers are registered dynamically, you should not assume that they will be processed in a particular order. Instead, you should program as though all event handlers will be executed simultaneously.

Reward if useful.