📄 zfir0020_alv_class.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>ZFIR0020_ALV_CLASS</title>
</head>
<body bgcolor="#FFFFE0">
<font size="3" face = "Arial" color="#000000"><b>Code listing for: ZFIR0020_ALV_CLASS</b></font>
<br>
<font size="3" face = "Arial" color="#000000"><b>Description: 金税下载ALV_CLASS</b></font>
<hr>
<pre width="100">
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Include ZFIR0020_ALV_CLASS</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
class lcl_alv_application definition. "定义事件
public section.
methods:
handle_double "执行双击事件
for event double_click of cl_gui_alv_grid
importing e_row e_column es_row_no,
handle_toolbar
for event toolbar of cl_gui_alv_grid "TOOLBAR
importing e_object e_interactive,
handle_user_command "执行toolbar的UCOMM
for event user_command of cl_gui_alv_grid
importing e_ucomm,
handle_menu_button
for event menu_button of cl_gui_alv_grid
importing e_object e_ucomm,
handle_data_changed
for event data_changed of cl_gui_alv_grid
importing er_data_changed e_onf4,
handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing e_row_id e_column_id es_row_no.
endclass. "lcl_event_receiver DEFINITION
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Class (Implementation) lcl_event_receiver</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">* Text</font>
<font color ="#0000FF">*----------------------------------------------------------------------*</font>
class lcl_alv_application implementation. "事件的实现
<font color ="#0000FF">*-----------------------------------------------------------------</font>
method handle_double .
endmethod. "HANDLE_double
<font color ="#0000FF">*-----------------------TOOLBAR------------------------------------*</font>
method handle_toolbar.
<font color ="#0000FF">* ?2.In event handler method for event TOOLBAR: Append own functions</font>
<font color ="#0000FF">* by using event parameter E_OBJECT.</font>
data: ls_toolbar type stb_button.
<font color ="#0000FF">*....................................................................</font>
<font color ="#0000FF">* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.</font>
<font color ="#0000FF">* This class has got one attribute, namly MT_TOOLBAR, which</font>
<font color ="#0000FF">* is a table of type TTB_BUTTON. One line of this table is</font>
<font color ="#0000FF">* defined by the Structure STB_BUTTON (see data deklaration above).</font>
<font color ="#0000FF">*</font>
<font color ="#0000FF">* A remark to the flag E_INTERACTIVE:</font>
<font color ="#0000FF">* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</font>
<font color ="#0000FF">* 'e_interactive' is set, if this event is raised due to</font>
<font color ="#0000FF">* the call of 'set_toolbar_interactive' by the user.</font>
<font color ="#0000FF">* You can distinguish this way if the event was raised</font>
<font color ="#0000FF">* by yourself or by ALV</font>
<font color ="#0000FF">* (e.g. in method 'refresh_table_display').</font>
<font color ="#0000FF">* An application of this feature is still unknown... :-)</font>
<font color ="#0000FF">*判断节点是否是根节点</font>
<font color ="#0000FF">*删除需要的ALV按钮</font>
<font color ="#0000FF">*把需要的引掉</font>
<font color ="#0000FF">* DELETE e_object->mt_toolbar WHERE FUNCTION = '&MB_SUM'.</font>
<font color ="#0000FF">* DELETE e_object->mt_toolbar WHERE FUNCTION = '&MB_SUBTOT'.</font>
delete e_object->mt_toolbar where function = '&&SEP05'.
delete e_object->mt_toolbar where function = '&PRINT_BACK'.
delete e_object->mt_toolbar where function = '&MB_VIEW'.
delete e_object->mt_toolbar where function = '&COL0'.
delete e_object->mt_toolbar where function = '&&SEP06'.
delete e_object->mt_toolbar where function = '&GRAPH'.
delete e_object->mt_toolbar where function = '&&SEP07'.
delete e_object->mt_toolbar where function = '&INFO'.
delete e_object->mt_toolbar where function = ''.
delete e_object->mt_toolbar where function = '&&SEP00'.
delete e_object->mt_toolbar where function = '&CHECK'.
delete e_object->mt_toolbar where function = '&LOCAL&CUT'.
delete e_object->mt_toolbar where function = '&LOCAL©'.
delete e_object->mt_toolbar where function = '&LOCAL&PASTE'.
delete e_object->mt_toolbar where function = '&LOCAL&APPEND'.
delete e_object->mt_toolbar where function = '&LOCAL&INSERT_ROW'.
DELETE e_object->mt_toolbar WHERE function = '&LOCAL&DELETE_ROW'.
delete e_object->mt_toolbar where function = '&LOCAL&UNDO'.
<font color ="#0000FF">* DELETE e_object->mt_toolbar WHERE FUNCTION = '&MB_SUM'.</font>
<font color ="#0000FF">* DELETE e_object->mt_toolbar WHERE FUNCTION = '&MB_SUBTOT'.</font>
delete e_object->mt_toolbar where function = '&MB_VIEW'.
delete e_object->mt_toolbar where function = '&GRAPH'.
delete e_object->mt_toolbar where function = '&INFO'.
DELETE e_object->mt_toolbar WHERE function = '&LOCAL©_ROW'.
delete e_object->mt_toolbar where function = '&REFRESH'.
"×××××××××××××××××加按钮
<font color ="#0000FF">* IF SY-TCODE <> 'ZBD002_22' AND SY-TCODE <> 'ZBD002_23'.</font>
<font color ="#0000FF">**分配方式</font>
<font color ="#0000FF">* CLEAR ls_toolbar.</font>
<font color ="#0000FF">* MOVE 3 TO ls_toolbar-butn_type.</font>
<font color ="#0000FF">* APPEND ls_toolbar TO e_object->mt_toolbar.</font>
<font color ="#0000FF">* CLEAR ls_toolbar.</font>
<font color ="#0000FF">* MOVE 'A_AVERAGE' TO ls_toolbar-function.</font>
<font color ="#0000FF">* MOVE icon_used_relation TO ls_toolbar-icon.</font>
<font color ="#0000FF">* MOVE '每征订代码按总数加权平均扣减'(114) TO ls_toolbar-quickinfo.</font>
<font color ="#0000FF">* MOVE 1 TO ls_toolbar-butn_type.</font>
<font color ="#0000FF">* MOVE ' ' TO ls_toolbar-disabled.</font>
<font color ="#0000FF">* APPEND ls_toolbar TO e_object->mt_toolbar.</font>
<font color ="#0000FF">* ENDIF.</font>
<font color ="#0000FF">*定义 创建alv按钮的宏</font>
define set_toolbar.
clear ls_toolbar.
move &1 to ls_toolbar-function.
move &2 to ls_toolbar-icon.
move &3 to ls_toolbar-butn_type. "按钮类型(父菜单) ' '不为父菜单
move &4 to ls_toolbar-quickinfo.
move &5 to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
end-of-definition.
clear ls_toolbar. "分割线
move '&&SEP07' to ls_toolbar-function.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
<font color ="#0000FF">*****自己加的按钮1</font>
<font color ="#0000FF">*ICON_CHANGE后面的不能为空,否则无法实现子菜单。</font>
set_toolbar 'SALL' ICON_SELECT_ALL '' '全选' ''.
set_toolbar 'CSALL' ICON_DESELECT_ALL '' '取消选择' ''.
set_toolbar 'DOWN' ICON_SUBMIT '' '金税下载处理' ''.
endmethod. "handle_toolbar
<font color ="#0000FF">*---------------user_command-----------------------------------*</font>
<font color ="#0000FF">*****对按钮的监听</font>
method handle_user_command.
CASE e_ucomm.
WHEN: 'SALL'.
LOOP AT IT_DATA INTO IT_DATA.
IT_DATA-DL = 'X'.
MODIFY IT_DATA FROM IT_DATA.
ENDLOOP.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
i_save = x_save
is_variant = ls_layout
is_layout = is_layout
CHANGING
<font color ="#0000FF">* IT_SORT = IT_SORT</font>
it_fieldcatalog = it_fieldcat
it_outtab = IT_DATA[].
WHEN: 'CSALL'.
LOOP AT IT_DATA INTO IT_DATA.
IT_DATA-DL = ''.
MODIFY IT_DATA FROM IT_DATA.
ENDLOOP.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
i_save = x_save
is_variant = ls_layout
is_layout = is_layout
CHANGING
<font color ="#0000FF">* IT_SORT = IT_SORT</font>
it_fieldcatalog = it_fieldcat
it_outtab = IT_DATA[].
WHEN: 'DOWN'.
<font color ="#0000FF">* BEGIN OF IT_DOWN OCCURS 0,</font>
<font color ="#0000FF">* aubel TYPE vbrp-aubel, "订单号</font>
<font color ="#0000FF">* stat_i TYPE zinvsta-stat_i,"发票状态</font>
<font color ="#0000FF">* d_place(1),"1.正常发票下载;2.作废发票下载</font>
<font color ="#0000FF">* END OF IT_DOWN.</font>
SORT IT_DATA BY KUNRG BSTNK VBELN.
LOOP AT IT_DATA INTO IT_DATA WHERE DL = 'X'.
SELECT SINGLE MATNR FKIMG INTO (IT_DOWN-MATNR,IT_DOWN-FKIMG)
FROM VBRP WHERE VBELN = IT_DATA-VBELN.
AT NEW KUNRG.
AT NEW BSTNK.
ENDAT.
ENDAT.
<font color ="#0000FF">* ON CHANGE OF WA_DATA-KUNRG.</font>
CLEAR IT_DOWN.
IT_DOWN-ZSERNR = ''.
IT_DOWN-ZVBELN = ''.
IT_DOWN-ZSTATU = '未回写'.
IT_DOWN-ZPOSNR = ''.
IT_DOWN-KUNRG = IT_DATA-KUNRG.
IT_DOWN-NAME1 = IT_DATA-NAME1.
IT_DOWN-FKART = IT_DATA-FKART.
IT_DOWN-FKDAT = IT_DATA-FKDAT.
APPEND IT_DOWN TO IT_DOWN.
<font color ="#0000FF">* ENDON.</font>
ENDLOOP.
PERFORM OUTPUT_DATA.
ENDCASE.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -