ABAP-AVL-OO方法中的ALV的如何自己添加按钮及其响应
1个回答
展开全部
步骤一:创建一个事件处理类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
*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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询