自己也发个东西,虽然很简单,有个R3的任务,要加个按钮,当时不会,今天看了下,在这谢谢翱翔云天的帮助。
REPORT Z_ALV_GRID_CONTROL.
CLASS lcl_event_receiver DEFINITION DEFERRED.
TABLES: sflight.
这是定义的container。
DATA: grid TYPE REF TO cl_gui_alv_grid,
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_sflight TYPE TABLE OF sflight.
DATA: ok_code LIKE sy-ucomm,
x_save,
GS_variant TYPE DISVARIANT,
g_repid TYPE sy-repid,
event_receiver type ref to lcl_event_receiver.
SELECT * FROM sflight
Into TABLE gt_sflight.
G_repid = sy-repid.
gs_variant-report = g_repid.
x_save = 'U'.
CALL SCREEN 100.
CLASS lcl_event_receiver 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.
* PRIVATE SECTION.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
按钮的属性。
DATA: ls_toolbar TYPE stb_button.
clear ls_toolbar.
move 1 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
* append an icon to show booking table
clear ls_toolbar.
move 'BOOKINGS' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Fuck'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
ENDMETHOD.
ENDCLASS.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
* SET TITLEBAR 'xxx'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT grid
EXPORTING
I_parent = g_custom_container.
CALL METHOD grid->set_table_for_first_display
EXPORTING I_structure_name = 'SFLIGHT'
* IS_Variant = gs_variant
* I_save = x_save
CHANGING IT_OUTTAB = gt_sflight.
这个是不能少的3句。
CREATE OBJECT event_receiver.
* SET HANDLER event_receiver->handle_user_command FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid.
CALL METHOD grid->set_toolbar_interactive.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
阅读(579) | 评论(1) | 转发(0) |