Code: Alles auswählen.
CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event implementation.
method handle_toolbar.
data: ls_toolbar TYPE stb_button.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'DELETE' to ls_toolbar-function.
move ICON_DELETE to ls_toolbar-icon.
Move 'Datei löschen'(t03) to ls_toolbar-quickinfo.
move space to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
endmethod.
ENDCLASS.
Code: Alles auswählen.
CALL METHOD z_grid_r->set_toolbar_interactive.
Code: Alles auswählen.
CALL METHOD grid_klasse->set_table_for_first_display
EXPORTING
* I_BYPASSING_BUFFER =
* i_buffer_active = 'X'
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = g_variant
i_save = 'A'
i_default = 'X'
is_layout = wa_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = it_alv
it_fieldcatalog = it_fieldcatalog.
* IT_FILTER = it_filter. "Filterkriterien
SET HANDLER lcl_event->handle_toolbar FOR grid_klasse.
SET HANDLER lcl_event->handle_user_command FOR grid_klasse.
CALL METHOD grid_klasse->set_toolbar_interactive.
Code: Alles auswählen.
REPORT zzz_test .
DATA: grid_klasse TYPE REF TO cl_gui_alv_grid,
container_klasse TYPE REF TO cl_gui_custom_container,
it_getraenke TYPE TABLE OF zgetraenke.
DATA: x_save, "for Parameter I_SAVE
g_repid LIKE sy-repid,
gs_layout TYPE disvariant. "for parameter IS_VARIANT
INCLUDE <icon>.
CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event implementation.
method handle_toolbar.
data: ls_toolbar TYPE stb_button.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'DELETE' to ls_toolbar-function.
move ICON_DELETE to ls_toolbar-icon.
Move 'Datei löschen'(t03) to ls_toolbar-quickinfo.
move space to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
endmethod.
ENDCLASS.
start-of-selection.
x_SAVE = 'u'.
g_repid = sy-repid.
gs_layout-report = g_repid.
SELECT * FROM zgetraenke INTO TABLE it_getraenke.
DATA: ls_toolbar TYPE stb_button.
CALL SCREEN 100.
*_________________PAI_____________________
MODULE user_command_0100 INPUT.
IF sy-ucomm ='BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*_________________PBO_____________________
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STANDARD'.
* SET TITLEBAR 'xxx'.
IF container_klasse IS INITIAL.
CREATE OBJECT container_klasse
EXPORTING container_name = 'CCCONTAINER'.
CREATE OBJECT grid_klasse
EXPORTING i_parent = container_klasse.
CALL METHOD grid_klasse->set_table_for_first_display
EXPORTING
i_structure_name = 'zgetraenke'
is_variant = gs_layout
i_save = x_save
CHANGING
it_outtab = it_getraenke.
SET HANDLER lcl_event->handle_toolbar FOR grid_klasse.
SET HANDLER lcl_event->handle_user_command FOR grid_klasse.
CALL METHOD grid_klasse->set_toolbar_interactive.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
Code: Alles auswählen.
* Nachdem du das Event lcl_event definiert hast
DATA: z_event_r TYPE REF TO lcl_event.
Code: Alles auswählen.
CLASS lcl_event IMPLEMENTATION
...
...
METHOD handle_user_command.
DATA: z_row TYPE i.
DATA: z_textline2(40) TYPE c.
DATA: z_answer(1) TYPE c.
DATA: z_fline TYPE i.
CASE e_ucomm.
WHEN 'DELETE'. "Datensatz löschen
PERFORM datensatz_loeschen.
ENDCASE.
ENDMETHOD.
ENDCLASS.
Code: Alles auswählen.
CREATE OBJECT z_event_r.
SET HANDLER z_event_r->handle_toolbar FOR grid_klasse.
SET HANDLER z_event_r->handle_user_command FOR gird_klasse.
CALL METHOD grid_klasse->set_toolbar_interactive.