TOP
data:gt_alv_100 like table of ztmm0001_po_head.
field-symbols <fs_100> like ztmm0001_po_head.
data:gt_alv_200 like table of ztmm0002_po_item.
field-symbols <fs_200> like ztmm0002_po_item.
data:go_100_cc type ref to cl_gui_custom_container,
go_100_split type ref to cl_gui_splitter_container,
go_101_split type ref to cl_gui_splitter_container.
data:go_200_cc type ref to cl_gui_container,
go_200_grid type ref to cl_gui_alv_grid.
data:gv_200_data type boolean,
gv_200_fill type boolean,
gv_200_refr type boolean.
data:gs_200_layout type lvc_s_layo,
gt_200_fcat type lvc_t_fcat,
gs_200_disvariant type disvariant,
gs_200_scroll_row type lvc_s_roid,
gs_200_scroll_col type lvc_s_col,
gt_200_selected_row type lvc_t_row,
gt_200_toolbar_ex type ui_functions.
field-symbols <fs_fcat_200> like lvc_s_fcat.
data:go_300_cc type ref to cl_gui_container,
go_300_grid type ref to cl_gui_alv_grid.
data:gv_300_data type boolean,
gv_300_fill type boolean,
gv_300_refr type boolean.
data:gs_300_layout type lvc_s_layo,
gt_300_fcat type lvc_t_fcat,
gs_300_disvariant type disvariant,
gs_300_scroll_row type lvc_s_roid,
gs_300_scroll_col type lvc_s_col,
gt_300_selected_row type lvc_t_row,
gt_300_toolbar_ex type ui_functions.
field-symbols <fs_fcat_300> like lvc_s_fcat.
data:go_400_cc type ref to cl_gui_container,
go_400_grid type ref to cl_gui_alv_grid.
data:gv_400_data type boolean,
gv_400_fill type boolean,
gv_400_refr type boolean.
data:gs_400_layout type lvc_s_layo,
gt_400_fcat type lvc_t_fcat,
gs_400_disvariant type disvariant,
gs_400_scroll_row type lvc_s_roid,
gs_400_scroll_col type lvc_s_col,
gt_400_selected_row type lvc_t_row,
gt_400_toolbar_ex type ui_functions.
field-symbols <fs_fcat_400> like lvc_s_fcat.
data:gs_stable type lvc_s_stbl.
CLS
class cl_200_event_handler definition.
public section.
class-methods:
handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column es_row_no,
handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing e_row_id e_column_id es_row_no,
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. "CL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*& Class (Implementation) cl_event_handler
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
class cl_200_event_handler implementation.
"双击行显示错误日志
method handle_double_click.
read table gt_alv_100 assigning <fs_100> index e_row-index.
select ebeln ebelp
into corresponding fields of table gt_alv_200
from ztmm0002_po_item
where ebeln eq <fs_100>-ebeln.
perform frm_200_scr_refresh.
endmethod. "handle_1100_data_changed
method handle_hotspot_click.
endmethod. "handle_1100_data_changed
method handle_toolbar.
field-symbols:
<fs_s_tb> type stb_button.
*----------------------------------------------------------------------*
* 新增button
*----------------------------------------------------------------------*
*分隔符
append initial line to e_object->mt_toolbar assigning <fs_s_tb>.
<fs_s_tb>-butn_type = 3.
* 数据校验
append initial line to e_object->mt_toolbar assigning <fs_s_tb>.
<fs_s_tb>-butn_type = 0."0 button;2 button list.
<fs_s_tb>-function = 'RECAL'.
<fs_s_tb>-icon = icon_check.
<fs_s_tb>-text = 'RECAL'.
* 确认执行
append initial line to e_object->mt_toolbar assigning <fs_s_tb>.
<fs_s_tb>-butn_type = 0."0 button;2 button list.
<fs_s_tb>-function = 'EXEC'.
<fs_s_tb>-icon = icon_execute_object.
<fs_s_tb>-text = 'EXEC'.
endmethod. "handle_toolbar
method handle_user_command.
"获取选中位置
perform frm_100_get_cursor.
*
perform frm_100_data_change.
* case e_ucomm.
* when 'RECAL'.
* when 'EXEC'.
* when '&IC1'.
* endcase.
*
* "数据刷新
perform frm_100_scr_refresh.
endmethod. "handle_user_command
endclass. "cl_event_handler IMPLEMENTATION
PRO
start-of-selection.
call screen 100.
FRM
*&---------------------------------------------------------------------*
*& Form FRM_200_BUILD_FCAT_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_200_build_fcat_list .
define fieldcat.
append initial line to gt_200_fcat assigning <fs_fcat_200>.
<fs_fcat_200>-fieldname = &1.
<fs_fcat_200>-coltext = &2.
end-of-definition.
fieldcat: 'EBELN' '采购订单号'.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_300_BUILD_FCAT_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_300_build_fcat_list .
define fieldcat.
append initial line to gt_300_fcat assigning <fs_fcat_300>.
<fs_fcat_300>-fieldname = &1.
<fs_fcat_300>-coltext = &2.
end-of-definition.
fieldcat: 'EBELN' '采购订单号'.
fieldcat: 'EBELP' '行项目'.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_200_SCR_REFRESH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_200_scr_refresh .
gs_stable-row = 'X'.
gs_stable-col = 'X'.
call method go_300_grid->refresh_table_display
exporting
is_stable = gs_stable
exceptions
finished = 1
others = 2.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_100_GET_CURSOR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_100_get_cursor .
if go_200_grid is bound.
* 得到选中行
go_200_grid->get_selected_rows(
importing
et_index_rows = gt_200_selected_row ).
* 得到位置
go_200_grid->get_scroll_info_via_id(
importing
es_row_no = gs_200_scroll_row
es_col_info = gs_200_scroll_col ).
endif.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_100_DATA_CHANGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_100_data_change .
go_200_grid->check_changed_data( ).
endform.
*&---------------------------------------------------------------------*
*& Form FRM_100_SCR_REFRESH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_100_scr_refresh .
gs_stable-row = 'X'.
gs_stable-col = 'X'.
call method go_200_grid->refresh_table_display
exporting
is_stable = gs_stable
exceptions
finished = 1
others = 2.
endform.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_300_DSP OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_300_dsp output.
if go_400_grid is not bound.
create object go_400_grid exporting i_parent = go_400_cc.
endif.
endmodule.
MOD
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
set pf-status 'ST_100'.
set titlebar 'T100'.
endmodule.
*&---------------------------------------------------------------------*
*& Module ALV_SCREEN_SPLIT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module alv_screen_split output.
* "alv splitter
if go_100_split is not bound.
if go_100_cc is not bound.
create object go_100_cc
exporting
container_name = 'ALV_CON'.
endif.
create object go_100_split
exporting
parent = go_100_cc
rows = 2
columns = 1.
* go_100_split->set_row_height(
* exporting
* id = 2
* height = 28 ).
endif.
"alv 子屏幕
if go_101_split is not bound.
create object go_101_split
exporting
parent = go_100_split->get_container( row = 1 column = 1 )
rows = 1
columns = 2.
*
* "alv 子屏幕
if go_200_cc is not bound.
go_200_cc = go_101_split->get_container( row = 1 column = 1 ).
endif.
if go_300_cc is not bound.
go_300_cc = go_101_split->get_container( row = 1 column = 2 ).
endif.
if go_400_cc is not bound.
go_400_cc = go_100_split->get_container( row = 2 column = 1 ).
endif.
endif.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_100_INIT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_100_init output.
if gv_200_data ne 'X'.
select *
up to 10 rows
into corresponding fields of table gt_alv_100
from ztmm0001_po_head.
gv_200_data = 'X'.
endif.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_100_DSP OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_100_dsp output.
if gv_200_fill <> 'X'.
* 创建Grid对象
if go_200_grid is not bound.
create object go_200_grid exporting i_parent = go_200_cc.
endif.
** 创建Field Catalog
perform frm_200_build_fcat_list.
*
** 创建toolbar excluding
* perform frm_200_build_toolbar_ex.
* 创建layout
gs_200_layout-cwidth_opt = 'X'."优化输出字段宽度
gs_200_layout-sel_mode = 'A'. "允许行选择
* gs_200_layout-box_fname = 'CHECK'. "选择
* gs_200_layout-no_toolbar = 'X'. "无按钮
* gs_200_layout-ctab_fname = 'CELLCOLORS'."颜色字段
* gs_200_layout-info_fname = 'ROWCOLOR'.
* 保存格式
clear gs_200_disvariant.
gs_200_disvariant-report = sy-repid.
gs_200_disvariant-handle = '200'.
gs_200_disvariant-username = sy-uname.
* 注册事件
set handler cl_200_event_handler=>handle_double_click for go_200_grid.
set handler cl_200_event_handler=>handle_toolbar for go_200_grid.
set handler cl_200_event_handler=>handle_user_command for go_200_grid.
set handler cl_200_event_handler=>handle_hotspot_click for go_200_grid.
* 第一次显示ALV
go_200_grid->set_table_for_first_display(
exporting
is_variant = gs_200_disvariant
i_save = 'U'
is_layout = gs_200_layout
it_toolbar_excluding = gt_200_toolbar_ex
changing
it_fieldcatalog = gt_200_fcat
it_outtab = gt_alv_100[] ).
gv_200_refr = gv_200_fill = abap_true.
else.
* 刷新ALV
if gv_200_refr <> abap_true.
go_200_grid->refresh_table_display( ).
gv_200_refr = abap_true.
endif.
* 设置选中行
if gt_200_selected_row is not initial.
go_200_grid->set_selected_rows(
exporting
it_index_rows = gt_200_selected_row ).
endif.
* 设置位置
if gs_200_scroll_row is not initial
or gs_200_scroll_col is not initial.
go_200_grid->set_scroll_info_via_id(
exporting
is_row_no = gs_200_scroll_row
is_col_info = gs_200_scroll_col ).
endif.
endif.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_200_INIT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_200_init output.
* suppress dialog.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_200_DSP OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_200_dsp output.
if gv_300_fill <> 'X'.
* 创建Grid对象
if go_300_grid is not bound.
create object go_300_grid exporting i_parent = go_300_cc.
endif.
** 创建Field Catalog
perform frm_300_build_fcat_list.
*
** 创建toolbar excluding
* perform frm_300_build_toolbar_ex.
* 创建layout
gs_300_layout-cwidth_opt = 'X'."优化输出字段宽度
gs_300_layout-sel_mode = 'A'. "允许行选择
* gs_200_layout-box_fname = 'CHECK'. "选择
* gs_200_layout-no_toolbar = 'X'. "无按钮
* gs_200_layout-ctab_fname = 'CELLCOLORS'."颜色字段
* gs_200_layout-info_fname = 'ROWCOLOR'.
* 保存格式
clear gs_300_disvariant.
gs_300_disvariant-report = sy-repid.
gs_300_disvariant-handle = '200'.
gs_300_disvariant-username = sy-uname.
* 第一次显示ALV
go_300_grid->set_table_for_first_display(
exporting
is_variant = gs_300_disvariant
i_save = 'U'
is_layout = gs_300_layout
it_toolbar_excluding = gt_300_toolbar_ex
changing
it_fieldcatalog = gt_300_fcat
it_outtab = gt_alv_200[] ).
gv_300_refr = gv_300_fill = abap_true.
else.
* 刷新ALV
if gv_300_refr <> abap_true.
go_300_grid->refresh_table_display( ).
gv_300_refr = abap_true.
endif.
* 设置选中行
if gt_300_selected_row is not initial.
go_300_grid->set_selected_rows(
exporting
it_index_rows = gt_300_selected_row ).
endif.
* 设置位置
if gs_300_scroll_row is not initial
or gs_300_scroll_col is not initial.
go_300_grid->set_scroll_info_via_id(
exporting
is_row_no = gs_300_scroll_row
is_col_info = gs_300_scroll_col ).
endif.
endif.
endmodule.
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module exit input.
leave to screen 0.
endmodule.
*&---------------------------------------------------------------------*
*& Module SCR_300_INIT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module scr_300_init output.
endmodule.
0100屏幕
process before output.
module status_0100.
module alv_screen_split.
module scr_100_init.
module scr_100_dsp.
module scr_200_init.
module scr_200_dsp.
module scr_300_init.
module scr_300_dsp.
process after input.
module exit at exit-command .
module user_command_0100.