2007 May 23 2:33 PM
Event handler class to handle double click of the user on alv grid.
such a class:
The class will be written in the main program or not?
Thanks.
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Hotspot click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no ,
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Hotspot Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD .
ENDCLASS .
FORM CREATEOBJECT.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .
ENDFORM.
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .
IF sy-subrc = 0." AND i_column_id-fieldname = 'SEATSOCC'.
CALL SCREEN 200 . "Details about passenger-seat matching
ENDIF .
ENDFORM .
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .
IF sy-subrc = 0." AND i_column-fieldname = 'SEATSOCC' .
CALL SCREEN 120 . "Details about passenger-seat matching
ENDIF .
ENDFORM .
2007 May 23 2:42 PM
Yes, you should write the class in your main program (definition and implementation). Here's an example:
&----
*& Class LCL_EVENT_HANDLER
&----
Text
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no e_column.
ENDCLASS. "LCL_EVENT_HANDLER
&----
*& Class (Implementation) lcl_event_handler
&----
Text
----
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
DATA: text TYPE string, es_row_text TYPE string.
es_row_text = es_row_no-row_id.
CONCATENATE 'You have selected row:' es_row_text 'and column:' e_column
INTO text SEPARATED BY ' '.
MESSAGE text TYPE 'I'.
ENDMETHOD. "on_double_click
ENDCLASS. "lcl_event_handler
In the main program you also need to define an instance of your class, like this:
DATA: r_handler TYPE REF TO lcl_event_handler.
Then after START-OF-SELECTION put this:
CREATE OBJECT r_handler.
Be sure to use something like this in your main program after you instantiate the ALV container:
SET HANDLER r_handler->on_double_click FOR r_alv_grid.
I hope this helps.
- April King
Event handler class to handle double click of the user on alv grid.
such a class:
The class will be written in the main program or not?
Thanks.
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Hotspot click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no ,
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Hotspot Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD .
ENDCLASS .
FORM CREATEOBJECT.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .
ENDFORM.
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .
IF sy-subrc = 0." AND i_column_id-fieldname = 'SEATSOCC'.
CALL SCREEN 200 . "Details about passenger-seat matching
ENDIF .
ENDFORM .
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .
IF sy-subrc = 0." AND i_column-fieldname = 'SEATSOCC' .
CALL SCREEN 120 . "Details about passenger-seat matching
ENDIF .
ENDFORM .
2007 May 23 2:37 PM
2007 May 23 2:38 PM
Hello,
Yes the idea is to do it during in the start of selection event.
Hope this helps,
Gabriel
2007 May 23 2:42 PM
Yes, you should write the class in your main program (definition and implementation). Here's an example:
&----
*& Class LCL_EVENT_HANDLER
&----
Text
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no e_column.
ENDCLASS. "LCL_EVENT_HANDLER
&----
*& Class (Implementation) lcl_event_handler
&----
Text
----
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
DATA: text TYPE string, es_row_text TYPE string.
es_row_text = es_row_no-row_id.
CONCATENATE 'You have selected row:' es_row_text 'and column:' e_column
INTO text SEPARATED BY ' '.
MESSAGE text TYPE 'I'.
ENDMETHOD. "on_double_click
ENDCLASS. "lcl_event_handler
In the main program you also need to define an instance of your class, like this:
DATA: r_handler TYPE REF TO lcl_event_handler.
Then after START-OF-SELECTION put this:
CREATE OBJECT r_handler.
Be sure to use something like this in your main program after you instantiate the ALV container:
SET HANDLER r_handler->on_double_click FOR r_alv_grid.
I hope this helps.
- April King
2007 May 23 3:27 PM
Dear April King
Thank you, thank you, thank you. I was in a trouble, you helped me very much.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |