The new ALV Display provides different events based on the class CL_SALV_EVENTS_TABLE. It is much lesser compared to the old ALV Display. The Events can be found in the ‘Events’ tab of the class.
Let us discuss about the following important Events of the class CL_SALV_EVENTS_TABLE.
Events | Description |
DOUBLE_CLICK | This event will be triggered, when the user double clicks. |
LINK_CLICK | This event will be triggered, when the user clicks on Hotspot or Button. Parameters are Row and Column |
ADDED_FUNCTION | The defined function will be triggered. The parameter is E_SALV_FUNCTION. |
The following steps are needed to facilitate an Event action.
- Define the Event handler
- Register the Event handler
- Definition of Event Handler
CLASS zcl_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS.
CLASS zcl_handler IMPLEMENTATION.
METHOD on_link_click.
FIELD-SYMBOLS <ls_contact> TYPE ztt_db_table2.
READ TABLE lt_contact INDEX row ASSIGNING <ls_contact>.
IF sy-subrc = 0 AND column = ‘CONTACT_ID’.
“” DETAILS OF THE CONTACT PERSON IS DISPLAYED.
ENDIF.
ENDMETHOD.
ENDCLASS.
- Register the Event Handler
START-OF-SELECTION.
DATA lr_salv_events_table TYPE REF TO cl_salv_events_table.
Lr_salv_events_table = lr_alv_grid->get_event( ).
SET HANDLER zcl_handler=>link_click FOR lr_salv_events_table.