06-20-2007 7:57 AM
06-21-2007 5:00 AM
06-20-2007 8:06 AM
Hi,
look at the below link
http://help.sap.com/saphelp_nw04/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm
Regards
Sudheer
06-20-2007 9:39 AM
Hi,
<b>Events</b>
Objects or classes can use events to trigger event handler methods in other objects or classes. In a normal method call, one method can be called by any number of users. When an event is triggered, any number of event handler methods can be called. The link between the trigger and the handler is not established until runtime. In a normal method call, the calling program determines the methods that it wants to call. These methods must exist. With events, the handler determines the events to which it wants to react. There does not have to be a handler method registered for every event.
The events of a class can be triggered in the methods of the same class using the RAISE EVENT statement. You can declare a method of the same or a different class as an event handler method for the event <evt> of class <class> using the addition FOR EVENT <evt> OF <class>.
Events have a similar parameter interface to methods, but only have output parameters. These parameters are passed by the trigger (RAISE EVENT statement) to the event handler method, which receives them as input parameters.
The link between trigger and handler is established dynamically in a program using the SET HANDLER statement. The trigger and handlers can be objects or classes, depending on whether you have instance or static events and event handler methods. When an event is triggered, the corresponding event handler methods are executed in all registered handling classes.
<b>Instance Events</b>
You declare instance events using the EVENTS statement. An instance event can only be triggered in an instance method.
<b>Static Events</b>
You declare static events using the CLASS-EVENTS statement. All methods (instance and static methods) can trigger static events. Static events are the only type of event that can be triggered in a static method.
Events Examples:
RIGHT_CLICK
TOOLBAR_MENUBUTTON_CLICK
CLICK_COL_HEADER
DBLCLICK_ROW_COL
CLICK_ROW_COL
TOOLBAR_BUTTON_CLICK
DOUBLE_CLICK_COL_SEPARAT
DELAYED_CHANGE_SELECTION
CONTEXT_MENU
TOTAL_CLICK_ROW_COL
CONTEXT_MENU_SELECTED
DOUBLE_CLICK
PRINT_TOP_OF_PAGE
PRINT_TOP_OF_LIST
PRINT_END_OF_PAGE
PRINT_END_OF_LIST
TOP_OF_PAGE
MENU_BUTTON
TOOLBAR
Regards,
Azaz Ali.
06-20-2007 9:48 AM
Hi,
Check out the link
http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
It gives a detailed description of events.
In general terms, event is a specific operation that happens.
Example can be a button click, a radiobutton selection, a sales order creation, a leave request creation.
Some specific operation needs to be done on this event. Event handler method recognize the event and start the operation.
Like on a button click i want to display some specific data.
Then button click is the event, An event handler method recognize this button click and call a form which gets the data from database and displays it in the form of some list.
Other links are
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/content.htm
Hope this explanation helps.
Regards,
Richa
06-20-2007 9:50 AM
Hi Sandeep,
Event is basically one of the components of a class. An event can be raised at certain points of program execution either by system or explicitly by the programmer. Whenever an event is raised control will flow to the handler methos defined and registered for the event. So the programmer can specify in the code the actions to be carried out when an event is raised, in the event hadler method.
Check the following program.
CLASS lcl_vehicle DEFINITION DEFERRED.
DATA: vehicle_list TYPE TABLE OF REF TO lcl_vehicle,
r_vehicles TYPE REF TO lcl_vehicle.
----
CLASS lcl_vehicle DEFINITION
----
*
----
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
EVENTS: vehicle_created.
METHODS: set IMPORTING im_make TYPE string
im_year TYPE i,
add_vehicle FOR EVENT vehicle_created OF lcl_vehicle
IMPORTING sender,
display_attributes.
CLASS-DATA:n_o_vehicles TYPE i.
PRIVATE SECTION.
DATA: make TYPE string, year TYPE i.
CLASS-DATA:n_o_vehicles TYPE i.
ENDCLASS. "lcl_vehicle DEFINITION
----
CLASS lcl_vehicle IMPLEMENTATION
----
*
----
CLASS lcl_vehicle IMPLEMENTATION.
METHOD set.
make = im_make.
year = im_year.
n_o_vehicles = n_o_vehicles + 1.
RAISE EVENT vehicle_created.
ENDMETHOD. "write:
METHOD add_vehicle.
APPEND sender TO vehicle_list.
ENDMETHOD. "add_vehicle
METHOD display_attributes.
WRITE: make, year.
ENDMETHOD. "display_attributes
ENDCLASS. "lcl_vehicle IMPLEMENTATION
DATA r_vehicle TYPE REF TO lcl_vehicle.
DATA r_vehicle1 TYPE REF TO lcl_vehicle.
START-OF-SELECTION.
CREATE OBJECT r_vehicle .
CREATE OBJECT r_vehicle1.
SET HANDLER r_vehicle1->add_vehicle FOR ALL INSTANCES.
FOR r_vehicle1.
SET HANDLER r_vehicle1->add_vehicle FOR r_vehicle1.
CALL METHOD r_vehicle->set
EXPORTING
im_make = 'Hyundai'
im_year = 2001.
CALL METHOD r_vehicle1->set
EXPORTING
im_make = 'Benz'
im_year = 2000.
LOOP AT vehicle_list INTO r_vehicles.
CALL METHOD r_vehicles->display_attributes.
ENDLOOP.
There are many applications of this. Suppose you are displaying a list output through ALV and requirement is whenever user double clicks on a line in ALV output, a message is to be displayed. For implementing this you can use the predefined event "double_click" in the ALV class <b>cl_gui_alv_grid</b>. In your program define a event handler method (in a local class) for this event and register the method for this event using SET HANDLER statement. Noew in the event handler method you can put in the code for displaying the message.
Check out the following link for more info on events.
http://help.sap.com/saphelp_47x200/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm
Award points if found useful.
Regards
Indrajit.
06-21-2007 5:00 AM
06-21-2007 7:00 AM
Hi,
Methods: handler_e1 handles event e1
handles events
e1 and e2
Publish and Subscribe
The ABAP Objects event concept provides a loose association between objects, where
The class (static event) or object (instance event) raising the event does not know who will respond
Potential responding classes or objects can decide for themselves whether to respond
ABAP Object events use the publish and subscribe approach: (1) A class declares an event and
implements a method to raise (publish) the event; (2) The same and/or other classes implement a
method to respond (subscribe) to the event; (3) At runtime, interested classes and objects register their wish and availability to respond.
Events Defining and Triggering
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS trigger_event.
EVENTS e1 EXPORTING
VALUE(e1)
CLASS-EVENTS:
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD trigger_event.
RAISE EVENT e1 EXPORTING
ENDMETHOD.
ENDCLASS.
INTERFACE i1.
METHODS trigger_event.
EVENTS e1 EXPORTING
VALUE(e1)
ENDINTERFACE.
Events can be declared as PUBLIC,
PROTECTED, or PRIVATE components of any
class or interface
There can be both instance and static events
The parameter interface for events is limited to
EXPORTING parameters, passed by VALUE
Events can be triggered by any method in the
class, using the RAISE EVENT statement
Events Handling
CLASS C2 DEFINITION.
PUBLIC SECTION.
METHODS event_handler FOR EVENT
e1 OF c1
IMPORTING e1.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD event_handler.
ENDMETHOD.
ENDCLASS.
Any class can define event handler methods for
the events of the class itself or for those of other
classes
Event handler methods use the FOR EVENT e1
OF {class | interface} addition
The event handlers parameter interface is limited
to importing those parameters defined in the
event declaration
The import parameters are not typed but adopt the
typing of the raised events exporting parameters
the interface is fully defined in the event declaration,
which helps make the trigger completely independent
of any potential handlers
Reward if u find helpful.
regards,
rajesh