CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'F_SET_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat[]
i_save = 'A' " 保存变式
is_variant = gs_variant "
TABLES
t_outtab = gt_itab[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
FORM f_set_status USING p_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD'.
ENDFORM. "F_SET_STATUS
步骤一:创建一个事件处理类CLASSlcl_event_receiverDEFINITION.*publicattributesandmethodPUBLICSECTION.METHODS:handle_toolbarFOREVENTtoolbarOFcl_gui_alv_gridIMPORTINGe_object,
handle_user_commandFOREVENTuser_commandOFcl_gui_alv_gridIMPORTINGe_ucomm,
ENDCLASS.
"lcl_event_receiverDEFINITION
注意这个事件处理类中添加了两个方法,第一个方法负责往工具栏上添加按钮,第二个方法用来响应工具栏上按钮的动作
步骤二:类的实现CLASSlcl_event_receiver
IMPLEMENTATION.
*methodtoolbarhandlerMETHODhandle_toolbar.PERFORMset_toolbarCHANGINGe_object.ENDMETHOD.
"handle_toolbarMETHODhandle_user_command.
*HandleownfunctionsdefinedinthetoolbarCASEe_ucomm.WHEN'ADD'.PERFORMxyz. “这里你想干嘛就可以干嘛ENDCASE.ENDMETHOD.
"handle_user_commandENDCLASS.
"lcl_event_receiverIMPLEMENTATION
步骤三:在FORM-----set_toolbar中添加buttonFORMset_toolbarCHANGINGprf_objectTYPEREFTOcl_alv_event_toolbar_set.CLEARprf_object-mt_toolbar.CLEARgs_toolbar.MOVE'ADD'TOgs_toolbar-function.MOVETOgs_toolbar-quickinfo.MOVETOgs_toolbar-text.MOVE''TOgs_toolbar-disabled.INSERTgs_toolbarINTOprf_object-mt_toolbarINDEX1.
ENDFORM.
"set_toolbar1
步骤四:创建事件处理对象--这一步一般在
grf_grid-set_table_for_first_display之后SETHANDLERgrf_event_receiver-handle_user_commandFORgrf_grid.SETHANDLERgrf_event_receiver-handle_toolbarFORgrf_grid.CALLMETHODgrf_grid-set_toolbar_interactive.
注意:STB_BUTTON结构包含的字段
FUNCTION UI_FUNC CHAR700Function Code
ICON ICONNAME CHAR300Name of an Icon
QUICKINFO ICONQUICKCHAR300Quickinfo for an icon
BUTN_TYPE TB_BTYPE INT4100Toolbar button type
DISABLED CHAR 10Disabled
TEXT TEXT40CHAR400Text, 40 Characters Long
CHECKED CHAR 10Printed
TB_BTYPE的可选择值 ,主要用来决定按钮的类型
0Button (normal)
1Menu and default button2Menu3Separator4Radio button5Checkbox6Menu entry
你把SET PF-STATUS '0200' EXCLUDING RT_EXTAB.改成SET PF-STATUS '0200' 这个看看,
如果还不行
CASE R_UCOMM改成 CASE SY-UCOMM
如果还不行
FUNCTION 'REUSE_ALV_GRID_DISPLAY'多开2个参数再看看
i_save = 'X'
i_callback_program = sy-repid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)