Restrict select-options to only allow specific restrictions


Example program to demonstrates how to restrict select-options to only allow specific restriction options
					i.e.. EQ, NE, CP, BT etc..          


*...............................................................
*: Report:  ZRESTRICT_SELOPT                                   :
*:                                                             :
*: Author:  www.SAPdev.co.uk                                   :
*:                                                             :
*: Date  :  2004                                               :
*:                                                             :
*: Description: Demonstrates how to restrict select options to :
*:              only allow specific restriction options:       :
*:                                     i.e.. EQ, NE, BT etc..  :
*:.............................................................:
REPORT ZRESTRICT_SELOPT.
* Include type pool SSCR
TYPE-POOLS sscr.
TABLES: EKPO.
* Selection-screen
select-options : so_ebeln for ekpo-ebeln,
                 so_ebelp for ekpo-ebelp.
* Variables for populating restriction data
DATA: gd_restrict TYPE sscr_restrict.   "structure containing 2 tables
DATA: gd_optlist  TYPE sscr_opt_list,   "header line for table 1
      gd_ass      TYPE sscr_ass.        "header line for table 2
************************************************************************
*INITIALIZATION.
INITIALIZATION.
* Restrict SO_EBELN to only except EQ, BT and NE.
  gd_optlist-name = 'KEY1'.      "Can be anything
  gd_optlist-options-eq = 'X'.
  gd_optlist-options-bt = 'X'.
  gd_optlist-options-ne = 'X'.
  APPEND gd_optlist TO gd_restrict-opt_list_tab.
  clear: gd_optlist.
  gd_ass-kind = 'S'.
  gd_ass-name = 'SO_EBELN'.
  gd_ass-sg_main = 'I'.
  gd_ass-sg_addy = SPACE.
  gd_ass-op_main = 'KEY1'.       "Must be same as above
  APPEND gd_ass TO gd_restrict-ass_tab.
  clear: gd_ass.
* Restrict SO_EBELP to only except CP, GE, LT.
  gd_optlist-name = 'KEY2'.      "Can be anything
  gd_optlist-options-cp = 'X'.
  gd_optlist-options-ge = 'X'.
  gd_optlist-options-lt = 'X'.
  APPEND gd_optlist TO gd_restrict-opt_list_tab.
  clear: gd_optlist.
  gd_ass-kind = 'S'.
  gd_ass-name = 'SO_EBELP'.
  gd_ass-sg_main = 'I'.
  gd_ass-sg_addy = SPACE.
  gd_ass-op_main = 'KEY2'.       "Must be same as above
  APPEND gd_ass TO gd_restrict-ass_tab.
  clear: gd_ass.
  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
   EXPORTING
*    PROGRAM                      =
    restriction                  = gd_restrict
*    DB                           = ' '
   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.

Related Articles

Adding buttons to an ABAP report selection screen within SAP
Add buttons to Application toolbar of selection screen
Add buttons with icon to selection screen
Add buttons to dynamically change the selection screen entry fields
ABAP parameter as checkbox plus initiate 'AT selection-screen' EVENT to unselect other checkboxes
Initiate the 'AT selection-screen' EVENT from a checkbox
Dynamically alter a selection screen based on user
SAP dropdown list box for an ABAP report selection screen
Initiate the 'AT selection-screen' EVENT from a LISTBOX within an ABAP report sel screen
ABAP Radiobutton to Initiate the 'AT selection-screen' EVENT on SAP report
ABAP Begin of Block to group selection-screen fields plus add title and frame
Report Selection Screen - Example code and information on various sel screen processing techniques
Selection screen push buttons
F4 search help manually called from report selection screen
Modify Selection Screen(LOOP AT SCREEN)
Radiobutton (inc desc) and entry field on same line of SAP selection screen
Add blank line to SAP report selection screen
Add Tab strip to Selection Screen