We can help. Together we learn....

Restricting range entry for select-option.

by Voice | Thursday, November 06, 2008 in |

Sometime it is required to restrict range input for a select option.  SAP provides an extension which is generally used for this is NO INTERVALS.

 Code:SELECT-OPTIONS: mat FOR mara-matnr NO INTERVALS.

 Apparently it seem that requirement is met but if someone presses multiple selection tab, a pop screen will open and there user can enter the range. This can also be restricted by using a function module SELECT_OPTIONS_RESTRICT.

 Example code:

**********************************************************************
* TYPE-POOLS:
**********************************************************************
TYPE-POOLS: sscr.
*----------------------------------------------------------------------*
* T A B L E S *
*----------------------------------------------------------------------*
TABLES: mara.
*----------------------------------------------------------------------*
* S E L E C T I O N S C R E E N *
*----------------------------------------------------------------------*
SELECTION-
SCREENBEGIN OF BLOCK b2 WITH FRAME.
SELECT-OPTIONS: mat FOR mara-matnr NO INTERVALS.
SELECT-OPTIONS: mtype FOR mara-mtart NO INTERVALS.
SELECTION-
SCREENEND OF BLOCK b2.

*---------------------------------------------------------------------*
* Initialization Event
*---------------------------------------------------------------------*
INITIALIZATION.

  
CONSTANTS: lc_opt_list TYPE rsrest_opl VALUE 'OPT_LIST',
             lc_s        
TYPE rsscr_kind VALUE 'S',
             lc_mat      
TYPE blockname  VALUE 'MAT',
             lc_inc      
TYPE c          VALUE 'I'.

  
DATA: lw_opt_list TYPE sscr_opt_list,
         lw_restrict 
TYPE sscr_restrict,
         lw_ass      
TYPE sscr_ass.

  lw_opt_list-name       = lc_opt_list.
  lw_opt_list-options-bt = space.
  lw_opt_list-options-
eq = 'X'.
  
APPEND lw_opt_list TO lw_restrict-opt_list_tab.

  lw_ass-kind    = lc_s.
  lw_ass-name    = lc_mat.
  lw_ass-sg_main = lc_inc.
  lw_ass-op_main = lc_opt_list.
  
APPEND lw_ass TO lw_restrict-ass_tab.

  
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    
EXPORTING
      restriction            = lw_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.




   With NO INTERVALS command. After pressing multiple selection tab you can enter range value.









After restricting with the function module you can not enter range value now.

There are other option available in this function module. Explore and enjoy :)

2 comments:

  1. Virgilio Israel Morales Galván on November 24, 2014 at 11:39 PM

    Thanks a lot for the information

     
  2. 77natas77 on September 15, 2016 at 7:42 PM

    I love you Dude! Good info.
    hahaha

     

Categories