Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Event for ABAP Objects

Former Member
0 Kudos

Dear All,

Would you mind tell me the concept of the event in the ABAP objects.

Regards,

Luke

4 REPLIES 4

Former Member
0 Kudos

hI

Triggering and Handling Events

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.

This section contains explains how to work with events in ABAP Objects. For precise details of the relevant ABAP statements, refer to the corresponding keyword documentation in the ABAP Editor.

Triggering Events

To trigger an event, a class must

· Declare the event in its declaration part

· Trigger the event in one of its methods

Declaring Events

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

EVENTS ) TYPE type ..

To declare static events, use the following statement:

CLASS-EVENTS ... ...

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

It can be

· An instance event declared in a class

· An instance event declared in an interface

· A static event declared in a class

· A static event declared in an interface

The syntax and effect of the SET HANDLER depends on which of the four cases listed above applies.

For an instance event, you must use the FOR addition to specify the instance for which you want to register the handler. You can either specify a single instance as the trigger, using a reference variable ...

The registration applies automatically to the whole class, or to all of the classes that implement the interface containing the static event. In the case of interfaces, the registration also applies to classes that are not loaded until after the handler has been registered.

Timing of Event Handling

After the RAISE EVENT statement, 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.

http://help.sap.com/saphelp_erp2004/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

http://help.sap.com/saphelp_erp2004/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

http://help.sap.com/saphelp_erp2004/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

http://help.sap.com/saphelp_erp2004/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

Former Member
0 Kudos

Here it is...

Events in ABAP Objects: Events are another kind of component in classes. They are declared in the declaration part of a class and raised in its methods. You declare events by using the statements EVENTS for instance events and CLASS-EVENTS for static events. Events can have EXPORTING parameters to pass parameters from the triggering object to the handler. Each instance event has an additional implicit parameter called SENDER. The SENDER data type is a reference variable to the respective sender class.

Static events can be raised in any method of the declaring class, whereas instance events can only be raised in instance methods. You raise an event in a method using the RAISE EVENT statement, and you pass arguments using the EXPORTING clause. For instance events, the system automatically passes the implicit parameter SENDER,which is a reference pointing to the object raising the event.

Any class may contain event handler methods for events of other classes. The event handler method signature (names and types of parameters) is not repeated but is taken from the event to be handled. However, the event handler method does not have to accept and use all of the parameters that the event defines. An event handler method can accept the implicit parameter SENDER like any other IMPORTING parameter, allowing it to access the triggering instance. The declaration of events and respective event handler methods in classes constitutes the static part of publish and subscribe.

Check the link for more detls..

http://www.intelligententerprise.com/channels/applications/feature/archive/heymann.jhtml?_requestid=...

Former Member
0 Kudos

Hi,

Triggering Events

RAISE EVENT <evt> EXPORTING... <ei> = <fi>...

The self-reference ME is automatically passed to the implicit parameter SENDER.

Handling Events

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

1. be defined as an event handler method for that event

2. be registered at runtime for the event.

Declaring Event Handler Methods

METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING.. <ei>..

The event handler method does not have to use all of the parameters passed in the RAISE EVENT statement.

If you want the implicit parameter SENDER to be used as well, you must list it in the interface.

Registering Event Handler Methods

SET HANDLER... <hi>... [FOR]...

Handler methods are executed in the order in which they were registered.

Check this.

http://help.sap.com/saphelp_nw04/helpdata/en/3f/818ea819e111d5969b00a0c94260a5/frameset.htm

http://www.henrikfrank.dk/abapuk.html

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20ea...

Regards,

Omkar.

Former Member
0 Kudos

Thank you very much