Monday, February 2, 2009

Restict Select-Option entries

When we press the "Multiple selection" button at the end of the SELECT-OPTIONS, we will get the following screen.







In the above screen, we might have to restict the user from entering the values in anyone or more tabs. For that we have to hid that tabs from display.

This can be achived using the follwoing code.

*&---------------------------------------------------------------------
*& Report ZNSTEST
*&---------------------------------------------------------------------
*&Written by Saravanan Natarajan.
*&Purpose : Restrict the select-options entries
*&---------------------------------------------------------------------
REPORT znstest.

TABLES : mara .
TYPE-POOLS : sscr .

SELECT-OPTIONS : s_matnr FOR mara-matnr.


INITIALIZATION.

PERFORM restrict_select_options.


START-OF-SELECTION.

Write : 'Code in START OF SELECTION'.

*&---------------------------------------------------------------------
*& Form restrict_select_option
*&---------------------------------------------------------------------
FORM restrict_select_options.
*-Local Data Declarations-*
DATA: str_restrict TYPE sscr_restrict,
str_opt_list TYPE sscr_opt_list,
str_ass TYPE sscr_ass.
*----------------------------------------------------------------------
*-Restrict Material Number-*

*-Create the str_ass entry to show that we are restricting S_MATNR
CLEAR str_ass.
str_ass-op_main = 'S_MATNR'.
str_ass-name = 'S_MATNR'.
str_ass-kind = 'S'.
str_ass-sg_main = '*'.

APPEND str_ass TO str_restrict-ass_tab.

*-Create str_opt_list, which specifies the options of S_MATNR
CLEAR: str_opt_list.
str_opt_list-name = 'S_MATNR'.
str_opt_list-options-eq = 'X'. "activate-include Single values
str_opt_list-options-ne = space. "Dont activate-exclude single values
str_opt_list-options-bt = space. "Dont activate-include ranges
str_opt_list-options-nb = space. "Dont activate-exclude ranges
str_opt_list-options-cp = space. "Dont activate- Include Pattern
str_opt_list-options-ge = space. "Dont activate- >=
str_opt_list-options-gt = space. "Dont activate- >
str_opt_list-options-le = space. "Dont activate- <= str_opt_list-options-lt = space. "Dont activate- < np =" space." restriction =" str_restrict" 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."> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. "restrict_select_options



Ouput of the above code:

When the "Multiple Selection" button is clicked


No comments:

Post a Comment