Application Development and Automation 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: 
Read only

Events in classes.

Former Member
0 Likes
819

Hi all

Can any one explain me the functionality about events and event handlers in ABAP OO??

Thanks and Regards,

Arun Joseph

Hi all

Can any one explain me the functionality about events and event handlers in ABAP OO??

Thanks and Regards,

Arun Joseph

5 REPLIES 5
Read only

Former Member
0 Likes
766

Hi Arun,

Please check this link

/message/5402992#5402992 [original link is broken]

http://www.erpgenie.com/index.php?option=com_content&task=view&id=21&Itemid=77

Best regards,

raam

Read only

0 Likes
766

Please dont send any links, i got enough links and documents with me..

Read only

uwe_schieferstein
Active Contributor
0 Likes
766

Hello Arun

Classes can have typical events, e.g. double-click, hotspot, context menu, expand folder etc. When you double-click on an ALV list the ALV grid instance "fires" the event DOUBLE_CLICK.

Every other instance which has been registered as event handler for this event (and the instance firing the event) is noticed by the "event handling" framework. In order to register for an event you

1) define a method as event handler and

2) register this method using the SET HANDLER statement, e.g.

SET HANDLER: lcl_eventhandler=>handle_double_click   FOR go_grid.  " register for single instance
SET HANDLER: lcl_eventhandler=>handle_double_click   FOR ALL INSTANCES.

For a sample report you may have a look at

Event handling is a general paradigm of any OO-language. Using events you can decouple the sender and receiver of the event. The sender instance has no clue about who are the receivers of a fired event.

Finally, if several event handlers are registered you cannot rely on any order of execution (which is synchronous).

Regards

Uwe

Read only

0 Likes
766

Hi there

Whilst the SENDER doesn't know about the RECEIVER the reverse is not true. Some people might (wrongly) infer from the comment about the sender that the receiver doesn't know either. I'm only adding the comment below hopefully to clear this up for some people who perhaps a new to OO programming and OO ABAP in particular.

By using the parameter SENDER the receiver can know what object triggered the event. This is of course useful where you have say multiple grid displays on the screen and an action needs to be performed depending on what object triggered it.



class lcl_event_handler definition.
************************************************************************
* CLASS     cl_event_receiver
* DEFINITION
************************************************************************
  public section.
    methods:
*--To add new functional buttons to the ALV toolbar
handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive
          sender,
*--To implement user commands
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm
          sender,
...
class lcl_event_handler  implementation.
*--Handle Toolbar
  method handle_toolbar.
*    PERFORM handle_toolbar USING e_object e_interactive .
  endmethod .
*--Handle Hotspot Click
  method handle_hotspot_click .
*    PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
.........

 create object  go_handler.

    set handler  go_handler->handle_user_command
    for go_grid1.

set handler  go_handler->handle_user_command
    for go_grid2.

......

form handle_toolbar
case g_sender
when go_grid1 

etc

sorry if this info is a case of "stating the obvious" but reading the forums there's quite a bit of confustion surronding event generation and handling in OO ABAP.

Cheers

jimbo

Read only

Former Member
0 Likes
766

event raise on control for example grip alv or text control.

this event respond and registered in application server by event handler