demo OO ALV 一些功能设定 下拉选择框 等 demo

ABAP用OO方式实现ALV

2012-05-23 13:27:17| 分类: ABAP | 标签:alv oo 面向对象 abap |举报|字号 订阅

report ytest_w_001.

*\功能A: 基本显示 *\功能B: 设定layout *\功能C: 设定fieldcat *\功能D: 增加复选框 *\功能E: 设定某列可输入 *\功能F: 设定某列为下拉列表

*\功能G: 设定屏蔽标准ALV 工具栏的按钮 *\功能H: 设定增加自定义ALV工具栏的按钮 *\功能I: 设定响应双击

*\功能J: 设定响应user command *\功能K: 设定TOP_OF_PAGE *\功能L: 设定动态修改layout *\功能M: 设定动态修改fieldcat

data: begin of gt_user occurs 0.\ne.

include structure usr02. data: checkbox(1),\功能D: 增加复选框 color(4). data: end of gt_user.

data: g_container type ref to cl_gui_custom_container.\功能A: 基本显示

data: g_grid type ref to cl_gui_alv_grid.\功能A: 基本显示 data: save_ok like sy-ucomm,

ok_code like sy-ucomm.

data: gt_fieldcat type lvc_t_fcat, \功能C: 设定fieldcat gs_fieldcat type lvc_s_fcat.\功能C: 设定fieldcat data: ls_layout type lvc_s_layo. \功能B: 设定layout

data: gt_exclude type ui_functions.\功能G: 设定屏蔽标准ALV 工具栏的按钮

*----------------------------------------------------------------------*

* CLASS lcl_event_handler DEFINITION

*----------------------------------------------------------------------* *

*----------------------------------------------------------------------*

class lcl_event_handler definition. public section.

methods handle_double for event double_click of cl_gui_alv_grid importing e_row e_column . \功能I: 设定响应双击

methods handle_toolbar for event toolbar of cl_gui_alv_grid importing e_object. \功能H: 设定增加自定义ALV工具栏的按钮

methods handle_user_command for event user_command of cl_gui_alv_grid importing e_ucomm. \功能J: 设定响应user command

methods handle_top for event top_of_page of cl_gui_alv_grid. \功能K: 设定TOP_OF_PAGE

endclass. \

*----------------------------------------------------------------------*

* CLASS lcl_event_handler IMPLEMENTATION

*----------------------------------------------------------------------* *

*----------------------------------------------------------------------*

class lcl_event_handler implementation.

method handle_double. \功能I: 设定响应双击

message i000(ih) with e_row-index e_column-fieldname. endmethod. \

method handle_toolbar. \功能H: 设定增加自定义ALV工具栏的按钮 data: ls_toolbar type stb_button. ls_toolbar-butn_type = '3'.

append ls_toolbar to e_object->mt_toolbar.

clear ls_toolbar.

ls_toolbar-text = 'Click'. ls_toolbar-function = 'Z1'.

ls_toolbar-icon = icon_calculation. *QUICKINFO *BUTN_TYPE

append ls_toolbar to e_object->mt_toolbar. endmethod. \

method handle_user_command. \功能J: 设定响应user command case e_ucomm. when 'Z1'.

message i000(ih) with 'Y'. endcase.

endmethod. \

method handle_top. \功能K: 设定TOP_OF_PAGE write:/ 'this is end'. message i000(ih) with 'hi'. endmethod.

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4