The class CL_GUI_ALV_GRID of the old ALV model provides different events. It is available in the Tab EVENTS of the class CL_GUI_ALV_GRID.
Event | Parameter | Description |
BUTTON_CLICK | E_ROW -> Row E_COLUMN -> Column E_ROW_NO -> Row id | It is triggered when a button is clicked. |
USER_COMMAND | E_UCOMM -> Function code | It is triggered when a function is triggered, |
DOUBLE_CLICK | E_ROW -> Row E_COLUMN -> Column E_ROW_NO -> Row Id | It is triggered when a cell of the ALV Table is double clicked. |
HOT_SPOT_CLICK | E_ROW -> Row E_COLUMN -> Column E_ROW_NO -> Row Id | It is triggered when a Hotspot is clicked. |
TOOLBAR | E_OBJECT -> It is an object of type CL_ALV_EVENT_TOOLBAR_SET | It is triggered when any entity on the toolbar is clicked. |
The implementation of the above events is similar for all events. It involves definition of Eventhandler, registering the Event handler with the SET HANDLER command.
The implementation of Double click event is shown below
CLASS zcl_handler DEFINITION PUBLIC.
PUBLIC SECTION.
CLASS_METHODS double_click_method FOR EVENT double_click
OF cl_gui_alv_grid IMPORTING e_row e_column es_row_no.
ENDCLASS.
CLASS zcl_handler IMPLEMENTATION.
METHOD double_click_method.
CALL FUNCTION ‘POPUP_TO_CONFIRM’
EXPORTING
titlebar = ‘Double Click occurred’
text_question = e_column-fieldname
text_button_1 = ‘Yes’
text_button_2 = ‘No’.
ENDMETHOD.
ENDCLASS.
Registration of Double Click event through SET HANDLER
SET HANDLER zcl_handler => double_click_method FOR lr_gui_alv_grid.
The class CL_GUI_ALV_GRID provides three methods to register events.
REGISTER_DELAYED_EVENT ( ) : If the cell of the ALV table or the line of record is changed, then this event can be used.
REGISTER_EDIT_EVENT ( ) :
If the data in the ALV is changed, then this event can be triggered automatically. The key benefit here is user does not have to click the ‘ENTER’ Button explicitly.
Let us look at this event with an example:
The edit event is registered with the help of the REGISTER_EDIT_EVENT method of the ALV object like below.
CALL METHOD lr_gui_alv_grid -> register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid => mc_evt_modified.
The parameter i_event_id is set to mc_evt_modified. By setting this event_id, the variable m_cell_edit is set explicitly to ‘X’. Even if the user forgets to click the enter key, then this variable m_cell_edit is set automatically.
REGISTER_F4_FOR_FIELDS ( ) :
If the F4- Value help for a field is clicked, then this event can be used.