ALV报表——点击事件(二)
目录
PS:请自行忽略gif的水印
一、复选框
ALV的复选框有两种方式实现,一种是使用Layout属性,另一种是使用Fieldcat属性
1、Layout实现方式(最简单的实现方式,这种方式能直接使用ALV报表自带的全选和反全选按钮,多选的话需要按住Ctrl再进行鼠标点选)
代码:
************************************************************************
* Program Name : ZMMR999
* Descriptions :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 20171223 1.0 xxx Create
*
************************************************************************
REPORT ZMMR999.
* Tables Definitions
************************************************************************
*TABLES:.
TABLES: marc,ekpo.
************************************************************************
* Data Definitions
************************************************************************
DATA: BEGIN OF gt_data OCCURS ,
checkbox TYPE c , "复选框
ebeln LIKE ekpo-ebeln, "PO
ebelp LIKE ekpo-ebelp, "PO项次
END OF gt_data. TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv. ************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY DEFAULT ''. SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln,
s_ebelp FOR ekpo-ebelp.
SELECTION-SCREEN END OF BLOCK b1. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION. ************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
END-OF-SELECTION. FORM get_data.
DATA: l_index LIKE sy-tabix. SELECT ebeln ebelp INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM ekpo
WHERE bukrs = p_werks
AND ebeln IN s_ebeln
AND ebelp IN s_ebelp. ENDFORM. *&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM display_data.
DATA: l_repid TYPE sy-repid,
l_inclname TYPE trdir-name,
l_index LIKE sy-tabix. CLEAR: gt_fieldcat[],wa_fieldcat. l_repid = l_inclname = sy-cprog. "栏位最适宽度
gs_layout-colwidth_optimize = 'X'.
"复选框
gs_layout-box_fieldname = 'CHECKBOX'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = l_repid
I_INTERNAL_TABNAME = 'GT_DATA'
I_INCLNAME = l_inclname
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE =
PROGRAM_ERROR =
OTHERS = . LOOP AT gt_fieldcat INTO wa_fieldcat.
l_index = sy-tabix. CASE wa_fieldcat-fieldname.
WHEN 'CHECKBOX'.
"技术字段,设置’X’后,该字段不会显示,也不能输出,如同MANDT字段一样的效果,不然会多出空列
wa_fieldcat-tech = 'X'.
ENDCASE. MODIFY gt_fieldcat FROM wa_fieldcat INDEX l_index.
ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
I_SAVE = 'A'
TABLES
T_OUTTAB = gt_data
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
ENDFORM.
运行效果:
2、Fieldcat实现方式(设置edit属性的时,会多出Layout方式的选择框效果,此复选框在此处无任何作用,未设置edit属性时,复选框在Fiori页面上又显示灰色,感觉不友好;不过Fieldcat实现方式不可使用ALV报表自带的全选和反全选按钮,需要自定义全选和反全选的点击按钮事件)
代码:
************************************************************************
* Program Name : ZMMR999
* Descriptions :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 20171223 1.0 xxx Create
*
************************************************************************
REPORT ZMMR999.
* Tables Definitions
************************************************************************
*TABLES:.
TABLES: marc,ekpo.
************************************************************************
* Data Definitions
************************************************************************
DATA: BEGIN OF gt_data OCCURS ,
checkbox TYPE c , "复选框
ebeln LIKE ekpo-ebeln, "PO
ebelp LIKE ekpo-ebelp, "PO项次
END OF gt_data. TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv. "ALV自定義按鈕
CONSTANTS alv_pf_status TYPE slis_formname VALUE 'ALV_PF_STATUS'.
*ALV自定義按鈕事件
CONSTANTS alv_user_command TYPE slis_formname
VALUE 'ALV_USER_COMMAND'.
************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY DEFAULT ''. SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln,
s_ebelp FOR ekpo-ebelp.
SELECTION-SCREEN END OF BLOCK b1. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION. ************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
END-OF-SELECTION. FORM get_data.
DATA: l_index LIKE sy-tabix. SELECT ebeln ebelp INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM ekpo
WHERE bukrs = p_werks
AND ebeln IN s_ebeln
AND ebelp IN s_ebelp. ENDFORM. *&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM display_data.
DATA: l_repid TYPE sy-repid,
l_inclname TYPE trdir-name,
l_index LIKE sy-tabix. CLEAR: gt_fieldcat[],wa_fieldcat. l_repid = l_inclname = sy-cprog. "栏位最适宽度
gs_layout-colwidth_optimize = 'X'.
"复选框
"gs_layout-box_fieldname = 'CHECKBOX'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = l_repid
I_INTERNAL_TABNAME = 'GT_DATA'
I_INCLNAME = l_inclname
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE =
PROGRAM_ERROR =
OTHERS = . LOOP AT gt_fieldcat INTO wa_fieldcat.
l_index = sy-tabix. CASE wa_fieldcat-fieldname.
WHEN 'CHECKBOX'.
"技术字段,设置’X’后,该字段不会显示,也不能输出,如同MANDT字段一样的效果
"wa_fieldcat-tech = 'X'. wa_fieldcat-seltext_s = wa_fieldcat-seltext_m =
wa_fieldcat-seltext_l = '复选框'.
wa_fieldcat-fix_column = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-hotspot = 'X'.
ENDCASE. MODIFY gt_fieldcat FROM wa_fieldcat INDEX l_index.
ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
I_CALLBACK_PF_STATUS_SET = 'ALV_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'
I_SAVE = 'A'
TABLES
T_OUTTAB = gt_data
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
ENDFORM. FORM alv_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS_POST' .
ENDFORM. " ALV_PF_STATUS FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield. DATA: ref TYPE REF TO cl_gui_alv_grid,
wa_data LIKE gt_data. DATA: l_index LIKE sy-index. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref.
CALL METHOD ref->check_changed_data. CASE in_ucomm.
WHEN '&ZALL'. "全选
LOOP AT gt_data.
l_index = sy-tabix.
gt_data-checkbox = 'X'.
MODIFY gt_data INDEX l_index.
ENDLOOP.
CALL METHOD ref->refresh_table_display. "刷新ALV data
WHEN '&ZSAL'. "反选
LOOP AT gt_data.
l_index = sy-tabix.
gt_data-checkbox = space.
MODIFY gt_data INDEX l_index.
ENDLOOP.
CALL METHOD ref->refresh_table_display. "刷新ALV data
WHEN '&IC1'. "单选,如果未设置 wa_fieldcat-hotspot,则为行双击
READ TABLE gt_data INTO wa_data INDEX in_selfield-tabindex.
LOOP AT gt_data.
l_index = sy-tabix.
IF l_index = in_selfield-tabindex.
IF in_selfield-fieldname = 'CHECKBOX'
AND wa_data-checkbox = space.
gt_data-checkbox = 'X'.
ELSEIF in_selfield-fieldname = 'CHECKBOX'
AND wa_data-checkbox = 'X'.
gt_data-checkbox = space.
ENDIF.
MODIFY gt_data INDEX l_index.
EXIT.
ENDIF.
ENDLOOP.
CALL METHOD ref->refresh_table_display.
" cl_demo_output=>write( in_selfield-tabindex ).
"cl_demo_output=>display( ).
WHEN '&DATA'.
cl_demo_output=>write( gt_data[] ).
cl_demo_output=>display( ).
ENDCASE.
ENDFORM.
自定义按钮:
运行效果:
3、拓展(单选某张PO的项次则改PO所有的项次全选)
代码:
************************************************************************
* Program Name : ZMMR999
* Descriptions :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 20171223 1.0 xxx Create
*
************************************************************************
REPORT ZMMR999.
* Tables Definitions
************************************************************************
*TABLES:.
TABLES: marc,ekpo.
************************************************************************
* Data Definitions
************************************************************************
DATA: BEGIN OF gt_data OCCURS ,
checkbox TYPE c , "复选框
ebeln LIKE ekpo-ebeln, "PO
ebelp LIKE ekpo-ebelp, "PO项次
END OF gt_data. TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv. "ALV自定義按鈕
CONSTANTS alv_pf_status TYPE slis_formname VALUE 'ALV_PF_STATUS'.
*ALV自定義按鈕事件
CONSTANTS alv_user_command TYPE slis_formname
VALUE 'ALV_USER_COMMAND'.
************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY DEFAULT ''. SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln,
s_ebelp FOR ekpo-ebelp.
SELECTION-SCREEN END OF BLOCK b1. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION. ************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
END-OF-SELECTION. FORM get_data.
DATA: l_index LIKE sy-tabix. SELECT ebeln ebelp INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM ekpo
WHERE bukrs = p_werks
AND ebeln IN s_ebeln
AND ebelp IN s_ebelp. SORT gt_data BY ebeln ebelp.
ENDFORM. *&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM display_data.
DATA: l_repid TYPE sy-repid,
l_inclname TYPE trdir-name,
l_index LIKE sy-tabix. CLEAR: gt_fieldcat[],wa_fieldcat. l_repid = l_inclname = sy-cprog. "栏位最适宽度
gs_layout-colwidth_optimize = 'X'.
"复选框
"gs_layout-box_fieldname = 'CHECKBOX'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = l_repid
I_INTERNAL_TABNAME = 'GT_DATA'
I_INCLNAME = l_inclname
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE =
PROGRAM_ERROR =
OTHERS = . LOOP AT gt_fieldcat INTO wa_fieldcat.
l_index = sy-tabix. CASE wa_fieldcat-fieldname.
WHEN 'CHECKBOX'.
"技术字段,设置’X’后,该字段不会显示,也不能输出,如同MANDT字段一样的效果
"wa_fieldcat-tech = 'X'. wa_fieldcat-seltext_s = wa_fieldcat-seltext_m =
wa_fieldcat-seltext_l = '复选框'.
wa_fieldcat-fix_column = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-hotspot = 'X'.
ENDCASE. MODIFY gt_fieldcat FROM wa_fieldcat INDEX l_index.
ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
I_CALLBACK_PF_STATUS_SET = 'ALV_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'
I_SAVE = 'A'
TABLES
T_OUTTAB = gt_data
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
ENDFORM. FORM alv_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS_POST' .
ENDFORM. " ALV_PF_STATUS FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield. DATA: ref TYPE REF TO cl_gui_alv_grid,
wa_data LIKE gt_data. DATA: l_index LIKE sy-index. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref.
CALL METHOD ref->check_changed_data. CASE in_ucomm.
WHEN '&ZALL'. "全选
LOOP AT gt_data.
l_index = sy-tabix.
gt_data-checkbox = 'X'.
MODIFY gt_data INDEX l_index.
ENDLOOP.
CALL METHOD ref->refresh_table_display. "刷新ALV data
WHEN '&ZSAL'. "反选
LOOP AT gt_data.
l_index = sy-tabix.
gt_data-checkbox = space.
MODIFY gt_data INDEX l_index.
ENDLOOP.
CALL METHOD ref->refresh_table_display. "刷新ALV data
WHEN '&IC1'. "单选,如果未设置 wa_fieldcat-hotspot,则为行双击
READ TABLE gt_data INTO wa_data INDEX in_selfield-tabindex.
IF in_selfield-fieldname = 'CHECKBOX'
AND wa_data-checkbox = space.
LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_temp>)
WHERE ebeln = wa_data-ebeln.
<fs_temp>-checkbox = 'X'.
ENDLOOP.
ELSEIF in_selfield-fieldname = 'CHECKBOX'
AND wa_data-checkbox = 'X'.
LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_temp2>)
WHERE ebeln = wa_data-ebeln.
<fs_temp2>-checkbox = space.
ENDLOOP.
ENDIF.
CALL METHOD ref->refresh_table_display.
" cl_demo_output=>write( in_selfield-tabindex ).
"cl_demo_output=>display( ).
WHEN '&DATA'.
cl_demo_output=>write( gt_data[] ).
cl_demo_output=>display( ).
ENDCASE.
ENDFORM.
运行效果:
二、点击事件
1、行双击:
代码:
************************************************************************
* Program Name : ZMMR999
* Descriptions :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 20171223 1.0 xxx Create
*
************************************************************************
REPORT ZMMR999.
* Tables Definitions
************************************************************************
*TABLES:.
TABLES: marc,ekpo.
************************************************************************
* Data Definitions
************************************************************************
DATA: BEGIN OF gt_data OCCURS ,
* checkbox TYPE c , "复选框
ebeln LIKE ekpo-ebeln, "PO
ebelp LIKE ekpo-ebelp, "PO项次
END OF gt_data. TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv. *ALV自定義按鈕事件
CONSTANTS alv_user_command TYPE slis_formname
VALUE 'ALV_USER_COMMAND'. ************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY DEFAULT ''. SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln,
s_ebelp FOR ekpo-ebelp.
SELECTION-SCREEN END OF BLOCK b1. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION. ************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
END-OF-SELECTION. FORM get_data.
DATA: l_index LIKE sy-tabix. SELECT ebeln ebelp INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM ekpo
WHERE bukrs = p_werks
AND ebeln IN s_ebeln
AND ebelp IN s_ebelp. SORT gt_data BY ebeln ebelp.
ENDFORM. *&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM display_data.
DATA: l_repid TYPE sy-repid,
l_inclname TYPE trdir-name,
l_index LIKE sy-tabix. CLEAR: gt_fieldcat[],wa_fieldcat. l_repid = l_inclname = sy-cprog. "栏位最适宽度
gs_layout-colwidth_optimize = 'X'.
"复选框
* gs_layout-box_fieldname = 'CHECKBOX'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = l_repid
I_INTERNAL_TABNAME = 'GT_DATA'
I_INCLNAME = l_inclname
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE =
PROGRAM_ERROR =
OTHERS = . LOOP AT gt_fieldcat INTO wa_fieldcat.
l_index = sy-tabix. CASE wa_fieldcat-fieldname.
* WHEN 'CHECKBOX'.
* "技术字段,设置’X’后,该字段不会显示,也不能输出,如同MANDT字段一样的效果,不然会多出空列
* wa_fieldcat-tech = 'X'.
ENDCASE. MODIFY gt_fieldcat FROM wa_fieldcat INDEX l_index.
ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'
I_SAVE = 'A'
TABLES
T_OUTTAB = gt_data
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
ENDFORM. FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield.
DATA: wa_data LIKE gt_data.
CASE in_ucomm.
WHEN '&IC1'. "行双击
READ TABLE gt_data INTO wa_data INDEX in_selfield-tabindex.
cl_demo_output=>write( wa_data ).
cl_demo_output=>display( ).
ENDCASE.
ENDFORM.
运行效果:
2、单元格双击事件(双击PO进入ME23N显示PO,双击物料进入MM03显示物料)
代码:
************************************************************************
* Program Name : ZMMR999
* Descriptions :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 20171223 1.0 xxx Create
*
************************************************************************
REPORT ZMMR999.
* Tables Definitions
************************************************************************
*TABLES:.
TABLES: marc,ekpo.
************************************************************************
* Data Definitions
************************************************************************
DATA: BEGIN OF gt_data OCCURS ,
* checkbox TYPE c , "复选框
ebeln LIKE ekpo-ebeln, "PO
ebelp LIKE ekpo-ebelp, "PO项次
END OF gt_data. TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv. *ALV自定義按鈕事件
CONSTANTS alv_user_command TYPE slis_formname
VALUE 'ALV_USER_COMMAND'. ************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY DEFAULT ''. SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln,
s_ebelp FOR ekpo-ebelp.
SELECTION-SCREEN END OF BLOCK b1. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION. ************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
END-OF-SELECTION. FORM get_data.
DATA: l_index LIKE sy-tabix. SELECT ebeln ebelp INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM ekpo
WHERE bukrs = p_werks
AND ebeln IN s_ebeln
AND ebelp IN s_ebelp. SORT gt_data BY ebeln ebelp.
ENDFORM. *&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM display_data.
DATA: l_repid TYPE sy-repid,
l_inclname TYPE trdir-name,
l_index LIKE sy-tabix. CLEAR: gt_fieldcat[],wa_fieldcat. l_repid = l_inclname = sy-cprog. "栏位最适宽度
gs_layout-colwidth_optimize = 'X'.
"复选框
* gs_layout-box_fieldname = 'CHECKBOX'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = l_repid
I_INTERNAL_TABNAME = 'GT_DATA'
I_INCLNAME = l_inclname
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE =
PROGRAM_ERROR =
OTHERS = . LOOP AT gt_fieldcat INTO wa_fieldcat.
l_index = sy-tabix. CASE wa_fieldcat-fieldname.
* WHEN 'CHECKBOX'.
* "技术字段,设置’X’后,该字段不会显示,也不能输出,如同MANDT字段一样的效果,不然会多出空列
* wa_fieldcat-tech = 'X'.
ENDCASE. MODIFY gt_fieldcat FROM wa_fieldcat INDEX l_index.
ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'
I_SAVE = 'A'
TABLES
T_OUTTAB = gt_data
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
ENDFORM. FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield.
DATA: wa_data LIKE gt_data.
CASE in_ucomm.
WHEN '&IC1'. "行双击
CASE in_selfield-fieldname. "双击的栏位名
WHEN 'EBELN'.
"PARAMETER ID通过F1->technical information->Parameter id可以获得
SET PARAMETER ID: 'BES' FIELD in_selfield-value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
运行效果:
ALV报表——点击事件(二)的更多相关文章
- juery下拉刷新,div加载更多元素并添加点击事件(二)
buffer.append("<div class='col-xs-3 "+companyId+"' style='padding-left: 10px; padd ...
- Unity UGUI按钮添加点击事件
1. 可视化创建及事件绑定 # 1 : 通过 Hierarchy 面板创建 UI > Button. 2 : 创建一个脚本 TestClick.cs, 定义了一个 Click 的 public ...
- 事件处理之二:点击事件监听器的五种写法 分类: H1_ANDROID 2013-09-11 10:32 4262人阅读 评论(1) 收藏
首选方法二! 方法一:写一个内部类,在类中实现点击事件 1.在父类中调用点击事件 bt_dail.setOnClickListener(new MyButtonListener()); 2.创建内部类 ...
- (二)AS给button添加点击事件
三种方法给Button添加点击事件 (一)通过button的id,添加继承View.OnClickListener的监听实现 <Button android:id="@+id/btn_ ...
- 帆软报表(finereport)点击事件对话框打开
点击事件对话框打开iframe var iframe = $("<iframe id='001' name='001' width='100%' height='100%' scrol ...
- HTML 事件(二) 事件的注册与注销
本篇主要介绍HTML元素事件的注册.注销的方式. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三) 事件流.事件委托 4. ...
- Android开发-之监听button点击事件
一.实现button点击事件的方法 实现button点击事件的监听方法有很多种,这里总结了常用的四种方法: 1.匿名内部类 2.外部类(独立类) 3.实现OnClickListener接口 4.添加X ...
- Android 防止多次点击事件
恐怕大家都会遇到这样的问题,一个点击事件多次触发,导致,同样的内容提交了多次,或者说弹出多个页面... 下面是简单的方案,大家可以试一试 原理很简单,当我们第一次点击的时候,把按钮变成不可点击状态. ...
- UIButton无法响应点击事件
一.问题描述 因为项目需要,需要UITableView上添加固定的筛选表头,一直固定,不能随UITableView滚动.所以直接将表头与UITableView分离,将它添加到控制器的UIView上,即 ...
随机推荐
- office project visio 2019
office2019,2016,2013,2010 Visio.Project 各版本下载激活!点我! http://blog.sina.com.cn/s/blog_170abd40a0102yah2 ...
- C# ZIP 压缩解压
ZIP流是在NetFramework4.5 引入的目的是为了能够更好的操作ZIP文件,进行压缩解压等操作.与ZIP流相关的几个类是: ZipArchive 代表一个ZIP的压缩包文件 ZipArchi ...
- SSM项目启动报错WEB-INF\lib\javax.servlet-api-4.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10
错误信息: validateJarFile(D:\tomcat_ryxunit\webapps\ryx_unit\WEB-INF\lib\javax.servlet.jar) - jar not lo ...
- gitlab 构建常见错误
1.前端是http服务后端是https,原因生产https,测试是http服务环境.代理后端2. java 打包程序需要运行正式数据库没连上错误.打包和跑正式的一个库.3. jenkins不能直接no ...
- flutter -------- 页面跳转和传值
在安卓原生开发中,页面跳转可以用Intent类来具体实现: Intent intent =new Intent(MainActivity.this,second.class); startActivi ...
- flutter 运行别人项目 包无法导入报错:Target of URI doesn't exist 'package:flutter/material.dart' 解决方法
命令行里运行 flutter packages get
- 在线http模拟工具
在线http模拟工具http://www.atool.org/httptest.php
- ISO/IEC 9899:2011 条款6.5.5——乘法操作符
6.5.5 乘法操作符 语法 1.multiplicative-expression: cast-expression multiplicative-expression * cast-e ...
- 【Tomcat】Tomcat 基本使用(二)
上一章介绍了Tomcat原理[Tomcat]Tomcat 原理架构(一),本章介绍Tomcat的基本使用 Tomcat端口设置 tomcat端口设置,在tomcat的配置文件目录下的server.xm ...
- win8(x64)下,重新安装delphi 2007时出现“Invalid Serial Number”,如何解决?
1)在添加删除程序里卸载delphi 2007 2)删除C:\ProgramData\CodeGear 3)删除C:\Program Files (x86)CodeGear 4)删除d:\Progra ...