ALV屏幕捕捉回车及下拉框事件&ALV弹出框回车及下拉框事件
示例展示:
屏幕依据输入的物料编码或下拉框物料编码拍回车自动带出物料描述:
点击弹出框,输入物料编码拍回车带出物料描述,点击确认,更新ALV:
1.创建屏幕9000,用于处理ALV弹出框:
2.针对屏幕9000画屏幕如下:
3.屏幕属性如下:
4.为屏幕9000设置OK_CODE接收屏幕回传值:
5.为屏幕9000设置状态栏,下拉框列表,命令执行:
6.为屏幕1000设置AG1状态栏
7.为屏幕9000设置AG2状态栏(ENTER用于接收弹出框回车事件):
8.全部代码如下:
*&---------------------------------------------------------------------*
*& Report ZTEST2
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTEST2.
TABLES: vbak,vbap.
TYPE-POOLS: slis.
DATA:t_fieldcat TYPE lvc_t_fcat,
w_fieldcat TYPE lvc_s_fcat,
t_layout TYPE lvc_s_layo.
DATA: gt_event TYPE slis_t_event,
gs_event LIKE LINE OF gt_event.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid.
DATA: stbl TYPE lvc_s_stbl.
DATA: le_row TYPE i,
le_value TYPE c,
le_col TYPE i,
les_row_id TYPE lvc_s_row,
les_col_id TYPE lvc_s_col,
les_row_no TYPE lvc_s_roid.
DATA gv_smart TYPE rs38l_fnam.
DATA: ok_code(3).
TYPES:BEGIN OF ty_result,
vbeln TYPE vbak-vbeln, "so
posnr TYPE vbap-posnr, "项目
ckbox TYPE char1,
matnr TYPE makt-matnr,
dlmatnr TYPE makt-matnr,
maktx TYPE makt-maktx,
dd_handle TYPE int4,
END OF ty_result.
DATA: gt_ddval TYPE lvc_t_drop,
gw_ddval TYPE lvc_s_drop.
DATA:t_result TYPE TABLE OF ty_result.
DATA:w_result TYPE ty_result.
DATA:parvw TYPE C LENGTH 2.
TYPES:BEGIN OF ty_vbakp,
vbeln TYPE vbak-vbeln, "so
posnr TYPE vbap-posnr, "项目
END OF ty_vbakp.
DATA:t_vbakp TYPE TABLE OF ty_vbakp,
w_vbakp TYPE ty_vbakp.
DATA:t_vbpa TYPE STANDARD TABLE OF vbpa,
w_vbpa TYPE vbpa.
DATA:rt_extab TYPE slis_t_extab.
SELECTION-SCREEN:BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN:END OF BLOCK a1.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_modify
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_modify.
* PERFORM refresh.
* Get the Current Cell
CALL METHOD ref_grid->get_current_cell
IMPORTING
E_ROW = le_row
E_VALUE = le_value
E_COL = le_col
ES_ROW_ID = les_row_id
ES_COL_ID = les_col_id
ES_ROW_NO = les_row_no.
READ TABLE t_result INTO w_result INDEX les_row_id-index.
IF sy-subrc = 0.
SELECT SINGLE maktx INTO w_result-maktx FROM makt WHERE matnr = w_result-matnr OR matnr = w_result-dlmatnr.
MODIFY t_result FROM w_result INDEX les_row_id-index.
stbl-row = 'X'." 基于行的稳定刷新
stbl-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable = stbl.
ENDIF.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS.
START-OF-SELECTION.
*-----------------------获取数据
PERFORM frm_get_data.
*-------------------------处理数据
PERFORM frm_handle_data.
IF t_result IS NOT INITIAL.
PERFORM frm_alv_show.
ELSE.
MESSAGE '没有符合的数据,请重新查询' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
END-OF-SELECTION.
FORM frm_get_data .
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_vbakp UP TO 5 ROWS
FROM vbak
JOIN vbap ON vbak~vbeln = vbap~vbeln
WHERE vbak~vbeln IN s_vbeln.
ENDFORM.
FORM frm_handle_data .
CLEAR w_vbakp.
LOOP AT t_vbakp INTO w_vbakp.
w_result-vbeln = w_vbakp-vbeln.
w_result-posnr = w_vbakp-posnr.
APPEND w_result TO t_result.
CLEAR w_result.
ENDLOOP.
ENDFORM. " FRM_HANDLE_DATA
*------展示ALV
FORM frm_alv_show.
PERFORM frm_init_layout.
PERFORM frm_set_fieldset.
PERFORM create_dropdown_values.
PERFORM frm_set_event.
PERFORM frm_output_alv.
PERFORM f_status USING rt_extab.
ENDFORM.
*------初始化ALV布局,可以自动根据数据长度调整列宽
FORM frm_init_layout.
t_layout-zebra = 'X'.
t_layout-box_fname = 'ckbox'.
ENDFORM.
*------该子程序主要用于设置ALV字段
FORM frm_set_fieldset.
PERFORM frm_init_fieldcat USING 'VBELN' '销售凭证' 'X' '' 10 ''.
PERFORM frm_init_fieldcat USING 'POSNR' '项目' 'X' '' 4 ''.
PERFORM frm_init_fieldcat USING 'MATNR' '物料编码' space 'X' 20 ''.
PERFORM frm_init_fieldcat USING 'DLMATNR' '物料编码' space 'X' 20 'DD_HANDLE'.
PERFORM frm_init_fieldcat USING 'MAKTX' '物料描述' space '' 40 ''.
ENDFORM.
FORM frm_init_fieldcat USING fieldcatname LIKE w_fieldcat-fieldname
seltext LIKE w_fieldcat-scrtext_l
selkey LIKE w_fieldcat-key
edit LIKE w_fieldcat-edit
len LIKE w_fieldcat-outputlen
drdn_field LIKE w_fieldcat-drdn_field.
.
CLEAR w_fieldcat.
w_fieldcat-fieldname = fieldcatname .
w_fieldcat-scrtext_l = seltext.
w_fieldcat-key = selkey.
w_fieldcat-edit = edit.
w_fieldcat-outputlen = len.
w_fieldcat-drdn_field = drdn_field.
APPEND w_fieldcat TO t_fieldcat.
ENDFORM.
FORM frm_output_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'F_STATUS '
i_callback_user_command = 'ALV_USER_COMMAND'
is_layout_lvc = t_layout
it_fieldcat_lvc = t_fieldcat
i_default = 'X'
i_save = 'A'
IT_EVENTS = gt_event
TABLES
t_outtab = t_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM f_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'AG1' EXCLUDING rt_extab.
"frm_platform_o
ENDFORM.
FORM alv_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield
TYPE slis_selfield.
CASE r_ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN '&IC1'."双击
IF rs_selfield-fieldname = 'VBELN'.
READ TABLE t_result INTO w_result INDEX rs_selfield-tabindex.
SET PARAMETER ID 'AUN' FIELD rs_selfield-value.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
CLEAR w_result.
ENDIF.
WHEN 'DIALOG'.
CALL SCREEN 9000 STARTING AT 20 10 ENDING AT 108 20 .
CHECK ok_code EQ 'YES'.
CLEAR ok_code.
PERFORM save_matnr.
ENDCASE.
ENDFORM.
FORM frm_set_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE
= 0
IMPORTING
ET_EVENTS
= gt_event
EXCEPTIONS
LIST_TYPE_WRONG
= 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID
TYPE SY-MSGTY
NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gs_event
-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gs_event
-FORM = 'FM_BUTTON'.
APPEND gs_event TO gt_event .
ENDFORM.
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
DATA gt_event_receiver TYPE REF TO lcl_event_receiver .
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid
= ref_grid.
*设置Dropdown List事件
CALL METHOD ref_grid->set_drop_down_table
EXPORTING
it_drop_down
= gt_ddval.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
CREATE OBJECT gt_event_receiver.
SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BRING_MAKTX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
DATA: p-maktx TYPE makt-maktx,
p
-matnr TYPE makt-matnr.
FORM BRING_MAKTX .
SELECT SINGLE maktx INTO p-maktx From makt WHERE matnr = p-matnr.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module LISTBOX_MATNR OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE LISTBOX_MATNR OUTPUT.
TYPE-POOLS vrm.
DATA: vid TYPE vrm_id VALUE 'P-MATNR',
vlist
TYPE vrm_values,
l_matnr
TYPE mara-matnr,
values
LIKE LINE OF vlist.
CLEAR vlist.
CLEAR values.
SELECT DISTINCT matnr INTO l_matnr FROM mara UP TO 10 ROWS WHERE matnr LIKE 'AA%'.
values
-key = l_matnr.
APPEND values TO vlist.
CLEAR values.
ENDSELECT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = vid
values
= vlist
EXCEPTIONS
id_illegal_name
= 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE '下拉框出错,请联系管理员!' TYPE 'I' DISPLAY LIKE 'S'.
ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'AG2'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
DATA lv_ok(3).
lv_ok
= ok_code.
CASE lv_ok.
WHEN 'YES' OR '&F1' OR 'CAN'.
LEAVE TO SCREEN 0.
WHEN 'ENT'.
PERFORM bring_maktx.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Form SAVE_MATNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SAVE_MATNR .
LOOP AT t_result INTO w_result WHERE ckbox = 'X'.
w_result
-matnr = p-matnr.
w_result
-dlmatnr = p-matnr.
w_result
-maktx = p-maktx.
MODIFY t_result FROM w_result.
CLEAR w_result.
ENDLOOP.
CLEAR ref_grid.
CLEAR stbl.
stbl
-col = 'X'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid
= ref_grid.
CALL METHOD ref_grid->check_changed_data.
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable
= stbl
i_soft_refresh
= 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_DROPDOWN_VALUES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_DROPDOWN_VALUES .
CLEAR w_result.
DATA: l_line TYPE i VALUE 0,
l_matnr
TYPE makt-matnr.
LOOP AT t_result INTO w_result.
ADD 1 TO l_line.
SELECT DISTINCT matnr INTO l_matnr UP TO 10 ROWS FROM makt WHERE matnr LIKE 'AA%'.
gw_ddval
-handle = l_line.
gw_ddval
-value = l_matnr.
APPEND gw_ddval TO gt_ddval.
ENDSELECT.
CLEAR gw_ddval.
w_result
-dd_handle = l_line.
MODIFY t_result FROM w_result.
CLEAR w_result.
ENDLOOP.
ENDFORM.
9.设置屏幕显示字段名称:
ALV屏幕捕捉回车及下拉框事件&ALV弹出框回车及下拉框事件的更多相关文章
- 手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法
手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法 最近碰到Android微信内置浏览H5页面,因为其中的文本输入框(input)放置在靠近页面的中下方,点击文本框以后,则输入框会被弹出的手机 ...
- 经验总结:WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
经验总结:WebBrowser自动点击弹出提示框alert.弹出对话框confirm.屏蔽弹出框.屏蔽弹出脚本错误的解决办法 网上有好多解决方法,可是不一定好使,本人经过多次试验,针对WebBrows ...
- 解决win10 cmd运行python弹出windows应用商店下python应用程序
方法一: 1.我一开始下载完python后,忘记下载到哪个位置,在win10底下输入框搜索python,点击打开文件所在位置,所在位置是python快捷键的位置,直接复制进行环境配置 配置完环境变量后 ...
- 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)
用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...
- phoenixframe自己主动化測试平台对div弹出框(如弹出的div登陆框)的处理
package org.phoenix.cases; import java.util.LinkedList; import org.phoenix.action.WebElementActionPr ...
- WPF弹出带蒙板的消息框
效果图 思路 拿到父级窗体的内容,放入一个容器里,再在容器里放入一个半透明层.将整个容器赋给父级窗体的内容. 关闭时反向操作. 代码 消息窗弹出时 /// <summary> /// 弹出 ...
- form WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
针对WebBrowser控件中自动点击弹出框及禁用脚本提示问题得到如下几种实际情况的解决办法,绝对管用. 1.屏蔽弹出错误脚本 将WebBrowser控件ScriptErrorsSuppressed设 ...
- vant - 弹框 【Popup 弹出层】【DatetimePicker 时间选择】
[HelloWorld.vue] <template> <div class="hello"> <van-row class="m-head ...
- [转]让程序不触发 Vista/Win7下应用程序兼容性助手弹出 .
原文地址 http://blog.csdn.net/maxuhuiabc/article/details/6081874 在Vista/Win7下 运行一个 exe 应用程序后,系统经常弹出 兼容性助 ...
随机推荐
- Django project troubleshootings
1. 当django project文件夹放到cgi-bin目录下面时会出现下面的错误: [Wed Jan 09 01:52:52.611690 2019] [core:notice] [pid 15 ...
- threejs 草场足球运动视角(三)
这次要模拟的场景如下图:就是在绿草地上足球的运动,并且视角会随着足球的运动发生变化,同时整个草地的视角也会旋转. 接下来,我们就对各个元素进行分析: 1,草地 用PlaneGeometry在三维空间里 ...
- krpano 常用标签
<krpano></krpano>根标签 相当于 <body> <scene></scene>一个全景图场景 <image> 图 ...
- SearchScore
static void Main(string[] args) { Console.WriteLine("请输入要查询的学生姓名!"); string nameToQuery = ...
- OceanBase迁移服务:向分布式架构升级的直接路径
2019年1月4日,OceanBase迁移服务解决方案在ATEC城市峰会中正式发布.蚂蚁金服资深技术专家师文汇和技术专家韩谷悦共同分享了OceanBase迁移服务的重要特性和业务实践. 蚂蚁数据库架构 ...
- Hadoop之HDFS概述
一.HDFS产生背景及定义 1.HDFS产生背景 随着数据量越来越大,在一个操作系统存不下所有的数据,那么就分配到更多的操作系统管理的磁盘中,但是不方便管理和维护,迫切需要一种系统来管理多台机器上的文 ...
- mysql log and lock
mysql bin log==> /etc/my.cnf==> log_bin=/var/log/mysql/mysql-bin.log==> binlog_do_db=your_d ...
- mint修改host
sudo xed /etc/hosts # Pycharm 0.0.0.0 account.jetbrains.com0.0.0.0 www.jetbrains.com #sublime text3 ...
- Git的基本使用教程
http://www.cnblogs.com/tugenhua0707/p/4050072.html 上传本地文件仓库到远程仓库大致步骤: 1.在安装完git时,先创建本地的一个仓库(新建一个文件夹) ...
- 关于java类加载机制的一些理解
关于java的类加载机制加载顺序,这个东西可以说是基础的东西,不过很遗憾这方面很多人也都不是很在意,比如我自己,最近上班闲下来了,就开始看一些博客文章了,今天恰好被一篇博文给吸引了,并且他的示例题一开 ...