* 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.