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'." 基于列稳定刷新