案列背景:
选择屏幕作为SUBSCREEN时,搜索条件中的域值或者F4的搜索帮助会失效。
优化前示例与效果截图:
*=======================================================================
* SELECTION-SCREEN " 选择屏幕定义
*=======================================================================
SELECTION-SCREEN BEGIN OF SCREEN 900 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_QYBM FOR ZRRE_D_XMTT-QYBM ,"区域编码
S_ZJBBM FOR ZRRE_D_XMTT-ZJBBM MATCHCODE OBJECT ZRRE_H_ZJBBM,"总监部编码
S_XMBM FOR ZRRE_D_XMTT-XMBM," 项目编码
S_BPNUM FOR ZRRE_D_BP-BPNUM,"客商编码
S_PLANNO FOR ZRRE_D_SETPLAN-SETPLANNO,
S_PLANNM FOR ZRRE_D_SETPLAN-SETPLANNM,
S_CONNO FOR /RER/D_BO_CONTH-CONNO,"系统合同编号
S_STATUS FOR /RER/D_BO_CONTH-APPSTATUS ."审批状态
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 900.
AT SELECTION-SCREEN OUTPUT.
*=======================================================================
* AT SELECTION-SCREEN ON VALUE-REQUEST
* 1、选择屏幕中,执行对应screen_id的F4帮助时触发
* 2、自定义搜索帮助事件块,用于用户输入帮助
*=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_XMBM-LOW.
PERFORM F4_XMBM USING 'S_XMBM-LOW'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_XMBM-HIGH.
PERFORM F4_XMBM USING 'S_XMBM-HIGH'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_QYBM-LOW.
PERFORM F4_RPRCT USING 'S_QYBM-LOW' CHANGING S_QYBM-LOW.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_QYBM-HIGH.
PERFORM F4_RPRCT USING 'S_QYBM-HIGH' CHANGING S_QYBM-HIGH.
优化后示例:
第一步:添加 TABBED BLOCK的声明:
SELECTION-SCREEN BEGIN OF TABBED BLOCK SUB FOR N LINES.
END OF BLOCK SUB.(SUB为block的命名,可随意自定义)
每个页签都是由一个单独的子屏幕控制,n代表分页控件的高度,屏幕载入时必须先通过INITIALIZATION事件对其属性初始化。
*=======================================================================
* SELECTION-SCREEN " 选择屏幕定义
*=======================================================================
SELECTION-SCREEN BEGIN OF SCREEN 900 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_QYBM FOR ZRRE_D_XMTT-QYBM ,"区域编码
S_ZJBBM FOR ZRRE_D_XMTT-ZJBBM MATCHCODE OBJECT ZRRE_H_ZJBBM,"总监部编码
S_XMBM FOR ZRRE_D_XMTT-XMBM," 项目编码
S_BPNUM FOR ZRRE_D_BP-BPNUM,"客商编码
S_PLANNO FOR ZRRE_D_SETPLAN-SETPLANNO,
S_PLANNM FOR ZRRE_D_SETPLAN-SETPLANNM,
S_CONNO FOR /RER/D_BO_CONTH-CONNO,"系统合同编号
S_STATUS FOR /RER/D_BO_CONTH-APPSTATUS ."审批状态
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 900.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,
END OF BLOCK SUB.
*=======================================================================
* AT SELECTION-SCREEN OUTPUT
*=======================================================================
AT SELECTION-SCREEN OUTPUT.
*=======================================================================
* AT SELECTION-SCREEN ON VALUE-REQUEST
* 1、选择屏幕中,执行对应screen_id的F4帮助时触发
* 2、自定义搜索帮助事件块,用于用户输入帮助
*=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_XMBM-LOW.
PERFORM F4_XMBM USING 'S_XMBM-LOW'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_XMBM-HIGH.
PERFORM F4_XMBM USING 'S_XMBM-HIGH'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_QYBM-LOW.
PERFORM F4_RPRCT USING 'S_QYBM-LOW' CHANGING S_QYBM-LOW.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_QYBM-HIGH.
PERFORM F4_RPRCT USING 'S_QYBM-HIGH' CHANGING S_QYBM-HIGH.
第二步:INITIALIZATION事件对其属性初始化。
(900为自定义的Subscreen的屏幕编号,根据实际情况确定)
*=======================================================================
* INITIALIZATION " 初始化选择屏幕上的变量
*=======================================================================
INITIALIZATION.
PERFORM INITIAL_DATA.
*&---------------------------------------------------------------------*
*& Form INITIAL_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM INITIAL_DATA .
SUB-PROG = SY-REPID.
SUB-DYNNR = 900.
ENDFORM.