Code: Alles auswählen.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler 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 ,
*--To implement user commands
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm ,
*--To be triggered before user commands
handle_before_user_command
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm ,
*--To be triggered after user commands
handle_after_user_command
FOR EVENT after_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm e_saved e_not_processed ,
*--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. "lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Toolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object e_interactive .
ENDMETHOD . "handle_toolbar
*--Handle User Command
METHOD handle_user_command .
PERFORM handle_user_command USING e_ucomm .
ENDMETHOD. "handle_user_command
*--Handle Before User Command JG
METHOD handle_before_user_command .
PERFORM handle_before_user_command USING e_ucomm .
ENDMETHOD . "handle_before_user_command
*--Handle After User Command JG
METHOD handle_after_user_command .
PERFORM handle_after_user_command USING e_ucomm e_saved e_not_processed .
ENDMETHOD . "handle_before_user_command
*--Double-click control
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS. "lcl_event_handler IMPLEMENTATION
DATA gr_event_handler TYPE REF TO lcl_event_handler .
:
:
*--Registering handler methods to handle ALV Grid events JG
SET HANDLER gr_event_handler->handle_double_click FOR grid1 .
SET HANDLER gr_event_handler->handle_toolbar FOR grid1.
SET HANDLER gr_event_handler->handle_user_command FOR grid1.
SET HANDLER gr_event_handler->handle_before_user_command FOR grid1 .
SET HANDLER gr_event_handler->handle_after_user_command FOR grid1 .
Code: Alles auswählen.
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_UCOMM text
*---------------------------------------------------------------------*
FORM handle_before_user_command USING i_ucomm TYPE syucomm .
CASE i_ucomm .
WHEN '&MB_FILTER' OR '&DELETE_FILTER' OR '&FILTER'.
ENDCASE .
ENDFORM . "handle_before_user_command
FORM handle_after_user_command USING e_ucomm e_saved e_not_processed .
break-point.
ENDFORM.
Folgende Benutzer bedankten sich beim Autor Tron für den Beitrag (Insgesamt 2):
Icke0801 • abapnewbie
Vielen Dank für den Tipp! Jetzt konnte ich durchs Abfangen der FCODES &FILTER und &MB_FILTER mein Ziel erreichen und die Filter-Logik vom refresh-Event trennen!Tron hat geschrieben: ↑30.07.2020 12:46Moin,
Clicken auf den Filter-Button, kann man über die Events
BEFORE_USER_COMMAND und AFTER_USER_COMMAND
abfangen.
Code: Alles auswählen.
*---------------------------------------------------------------------* * CLASS lcl_event_handler DEFINITION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS lcl_event_handler 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 , *--To implement user commands handle_user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm , *--To be triggered before user commands handle_before_user_command FOR EVENT before_user_command OF cl_gui_alv_grid IMPORTING e_ucomm , *--To be triggered after user commands handle_after_user_command FOR EVENT after_user_command OF cl_gui_alv_grid IMPORTING e_ucomm e_saved e_not_processed , *--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. "lcl_event_handler DEFINITION *---------------------------------------------------------------------* * CLASS lcl_event_handler IMPLEMENTATION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS lcl_event_handler IMPLEMENTATION . *--Handle Toolbar METHOD handle_toolbar. PERFORM handle_toolbar USING e_object e_interactive . ENDMETHOD . "handle_toolbar *--Handle User Command METHOD handle_user_command . PERFORM handle_user_command USING e_ucomm . ENDMETHOD. "handle_user_command *--Handle Before User Command JG METHOD handle_before_user_command . PERFORM handle_before_user_command USING e_ucomm . ENDMETHOD . "handle_before_user_command *--Handle After User Command JG METHOD handle_after_user_command . PERFORM handle_after_user_command USING e_ucomm e_saved e_not_processed . ENDMETHOD . "handle_before_user_command *--Double-click control METHOD handle_double_click . PERFORM handle_double_click USING e_row e_column es_row_no . ENDMETHOD . "handle_double_click ENDCLASS. "lcl_event_handler IMPLEMENTATION DATA gr_event_handler TYPE REF TO lcl_event_handler . : : *--Registering handler methods to handle ALV Grid events JG SET HANDLER gr_event_handler->handle_double_click FOR grid1 . SET HANDLER gr_event_handler->handle_toolbar FOR grid1. SET HANDLER gr_event_handler->handle_user_command FOR grid1. SET HANDLER gr_event_handler->handle_before_user_command FOR grid1 . SET HANDLER gr_event_handler->handle_after_user_command FOR grid1 .
gruß JensCode: Alles auswählen.
*&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * -->I_UCOMM text *---------------------------------------------------------------------* FORM handle_before_user_command USING i_ucomm TYPE syucomm . CASE i_ucomm . WHEN '&MB_FILTER' OR '&DELETE_FILTER' OR '&FILTER'. ENDCASE . ENDFORM . "handle_before_user_command FORM handle_after_user_command USING e_ucomm e_saved e_not_processed . break-point. ENDFORM.