Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding patterns in select-option

Former Member
0 Kudos

Hi All,

I have a small requirment i have a selectoption in selection screen like this

select-option: s_draw for w_draw nointervals no-extension.

s_draw is of char10,

if user entered patterns in this field i need to display an error message, and at the same time it is not possible for me to declare as a parameter because this selection screen is used by more than one program where user are eligible to enter patterns in another program.so could any one suggest me how we will get this.

Thanks in advance

Regards,

Sarala.

1 ACCEPTED SOLUTION

former_member183890
Participant
0 Kudos

Hi,

It is simple.

read table s_draw with key OPTION = 'CP'.

if sy-subrc = 0.

message e001....

endif.

CP - Contains pattern.

This will definitly solve the issue. Reward points if helpful.

- Irudayaraj Peter

5 REPLIES 5

0 Kudos

Hi,

Generally people will enter patterns using the characters like * or ? or %. so search for these characters and then raise a message if they appear in your select options low or high.

LOOP AT sel_crit.

FIND '*' IN sel_crit-low.

if sy-subrc = 0.

message 'illegal char' type 'E'.

endif.

FIND '*' IN sel_crit-high.

if sy-subrc = 0.

message 'illegal char' type 'E'.

endif.

FIND '?' IN sel_crit-low.

if sy-subrc = 0.

message 'illegal char' type 'E'.

endif.

FIND '?' IN sel_crit-high.

if sy-subrc = 0.

message 'illegal char' type 'E'.

endif.

ENDLOOP.

Regards,

Sesh

0 Kudos

Hi Thanks for your replay,

But only these 3 char it is fine what about others.

it is difficult to compare all these chars right.

Former Member
0 Kudos

Hi,

you need to sue the function module 'SELECT_OPTIONS_RESTRICT' for this one ..

here is the example to restrict the select-option

REPORT selectoptionsrestrict. 
* Include type pool SSCR 
TYPE-POOLS sscr. 
TABLES : 
  marc. 
* defining the selection-screen 
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. 
* Restricting the MATNR selection to only EQ and '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. 
* Restricting the WERKS selection to 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 
   &nbs! p; 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

Regards

Sudheer

former_member183890
Participant
0 Kudos

Hi,

It is simple.

read table s_draw with key OPTION = 'CP'.

if sy-subrc = 0.

message e001....

endif.

CP - Contains pattern.

This will definitly solve the issue. Reward points if helpful.

- Irudayaraj Peter

0 Kudos

hi,

My problem got solved.

Thanks.