To andle the Double Click event of SALV, we need to declare a handler class:
Definition:
CLASS lcl_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_double_click FOR EVENT DOUBLE_CLICK OF cl_salv_events_table
IMPORTING row column.
PRIVATE SECTION.
DATA: lr_data_tab TYPE REF TO data.
ENDCLASS.
The method handler returns the row and columns double clicked.
Implementation:
This is what the method must do after a row is double clicked, reading the table using the row as the index.
CLASS lcl_handler IMPLEMENTATION.
METHOD on_double_click.
READ TABLE SALVTable INTO WA_SALVTable INDEX row.
"...
"...
"...
ENDMETHOD.
ENDCLASS.
Then we need to declare the handler class and cl_salv_events_table class as REF TO
DATA: r_events TYPE REF TO cl_salv_events_table,
event_handler type ref to lcl_handler.
We gets the event object from the alv object created by factory method of cl_salv_table:
r_events = alv->get_event( ).
Then Create the event handler
CREATE OBJECT event_handler.
Sets the handler method for the ALV corresponding event
SET HANDLER event_handler->on_double_click FOR r_events.
We are finished.
Definition:
CLASS lcl_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_double_click FOR EVENT DOUBLE_CLICK OF cl_salv_events_table
IMPORTING row column.
PRIVATE SECTION.
DATA: lr_data_tab TYPE REF TO data.
ENDCLASS.
The method handler returns the row and columns double clicked.
Implementation:
This is what the method must do after a row is double clicked, reading the table using the row as the index.
CLASS lcl_handler IMPLEMENTATION.
METHOD on_double_click.
READ TABLE SALVTable INTO WA_SALVTable INDEX row.
"...
"...
"...
ENDMETHOD.
ENDCLASS.
Then we need to declare the handler class and cl_salv_events_table class as REF TO
DATA: r_events TYPE REF TO cl_salv_events_table,
event_handler type ref to lcl_handler.
We gets the event object from the alv object created by factory method of cl_salv_table:
r_events = alv->get_event( ).
Then Create the event handler
CREATE OBJECT event_handler.
Sets the handler method for the ALV corresponding event
SET HANDLER event_handler->on_double_click FOR r_events.
We are finished.
No hay comentarios:
Publicar un comentario