原文地址:http://blog.tom.com/lxd_52_zl/article/7407.html
ECC6己测试,通过!
TYPE-POOLS SSCR.
TYPE SSCR_RESTRICT,
OPTLIST TYPE SSCR_ASS.
SELECTION-BEGIN BLOCK BLK FRAME TEXT-SELECT-OPTIONS S_DATE NO INTERVALS SCREEN OF INITIALIZATION.
OPTLIST-NAME = EQ = " 控制显示条件 EQ 等于
OPTLIST-OPTIONS-BT = APPEND OPTLIST 'S'.
ASS-NAME = 'I'.
ASS-SG_ADDY = SPACE.
ASS-OP_MAIN = APPEND ASS CALL 'SELECT_OPTIONS_RESTRICT'
EXCEPTIONS
TOO_LATE = 2
selopt_without_options = 4
invalid_sign = 6
invalid_kind = 8
9.
START-WRITE: /
备注,下面给出需要控制的条件
*NO-EXTENSION
*NO INTERVALS
*BT SELECT-OPTIONS: 活动范围
*CP 选项: 活动模式
*EQ 选项: 单一活动值
*GE 选项: 大于或等于
*GT 选项: 大于
*LE 选项: 小于或等于
*LT 选项: 小于
*NB SELECT-OPTIONS: 排除范围激活
*NE SELECT-OPTIONS: 单值活动除外
*NP 选项: 活动的模型除外
----------------------------------------------
REPORT Z_CONECT_A.
* Include type pool SSCR
TYPE-POOLS sscr.
TABLES : marc.
*定义选择屏幕select-options :
s_matnr for marc-matnr,
s_werks for marc-werks.
* Define the object to be passed to the RESTRICTION parameter
DATA restrict TYPE sscr_restrict.
* Auxiliary objects for filling RESTRICT
DATA : optlist TYPE sscr_opt_list,
ass type sscr_ass.
INITIALIZATION.
* 限制MATNR参数只能使用‘EQ’ 和‘BT’.
optlist-name = 'OBJECTKEY1'.
optlist-options-eq = 'X'.
optlist-options-bt = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_MATNR'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY1'.
APPEND ass TO restrict-ass_tab.
* 限制 WERKS 参数只能使用CP, GE, LT, NE.
optlist-name = 'OBJECTKEY2'.
optlist-options-cp = 'X'.
optlist-options-ge = 'X'.
optlist-options-lt = 'X'.
optlist-options-ne = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_WERKS'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY2'.
APPEND ass TO restrict-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
restriction = restrict
EXCEPTIONS
TOO_LATE = 1
REPEATED = 2
SELOPT_WITHOUT_OPTIONS = 3
SELOPT_WITHOUT_SIGNS = 4
INVALID_SIGN = 5
EMPTY_OPTION_LIST = 6
INVALID_KIND = 7
REPEATED_KIND_A = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.