Use FM SELECT_OPTIONS_RESTRICT.
TYPE-POOLS sscr.
TABLES : marc.
* Selection screen !
SELECT-OPTIONS :
s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
INITIALIZATION.
* Define the object to be passed to the RESTRICTION parameter
DATA ls_restrict TYPE sscr_restrict.
* Auxiliary objects for filling RESTRICT
DATA : ls_optlist TYPE sscr_opt_list,
ls_ass TYPE sscr_ass.
" Défine option list (will be used for MATNR)
ls_optlist-name = 'MY_RESTRICT_EQ_BT'.
ls_optlist-options-eq = 'X'.
ls_optlist-options-BT = 'X'.
APPEND ls_optlist TO ls_restrict-opt_list_tab.
CLEAR ls_optlist.
" Défine option list (will be used for WERKS)
ls_optlist-name = 'RESTRICT_CP_GE_LT_NE'.
ls_optlist-options-cp = 'X'.
ls_optlist-options-ge = 'X'.
ls_optlist-options-lt = 'X'.
ls_optlist-options-ne = 'X'.
APPEND ls_optlist TO ls_restrict-opt_list_tab.
* List of option list available :
* -------------------------------
* BT SELECT-OPTIONS : intervalle actif
* CP SELECT-OPTIONS : modèle actif
* EQ SELECT-OPTIONS : val. indiv. active
* GE SELECT-OPTIONS : supérieur ou égal actif
* GT SELECT-OPTIONS : supérieur actif
* LE SELECT-OPTIONS : inférieur ou égal actif
* LT SELECT-OPTIONS : inférieur actif
* NB SELECT-OPTIONS : exclure intervalle actif
* NE SELECT-OPTIONS : exclure valeur individuelle actif
* NP SELECT-OPTIONS : exclure modèle actif
* Restricting the MATNR selection to only EQ & BT.
ls_ass-kind = 'S'.
ls_ass-name = 'S_MATNR'.
ls_ass-sg_main = 'I'.
ls_ass-sg_addy = space.
ls_ass-op_main = 'MY_RESTRICT_EQ_BT'.
APPEND ls_ass TO ls_restrict-ass_tab.
* Restricting the WERKS selection to CP, GE, LT, NE.
ls_ass-kind = 'S'.
ls_ass-name = 'S_WERKS'.
ls_ass-sg_main = 'I'.
ls_ass-sg_addy = space.
ls_ass-op_main = 'RESTRICT_CP_GE_LT_NE'.
APPEND ls_ass TO ls_restrict-ass_tab.
" Apply restrictions
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
restriction = ls_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.
Result :
About the author