Application Development and Automation 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: 
Read only

select-option

Former Member
0 Likes
909

Hi.

I don't want to give the user the possibility to select a range, select values "greater than", etc.

I got sample code from but its not working perfectly.could you help me ,in this senario?

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/840ad679-0601-0010-cd8e-9989fd65...

Code as follows.


REPORT ZDANY_RESTRICT_SELECTION.
					
* Include type pool SSCR
    TYPE-POOLS sscr.
    TABLES : sflight.
					
* defining the selection-screen
    select-options :
        s_carrid for sflight-carrid,
        s_connid for sflight-connid.
					
* 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 carrid 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_carrid'.
    ass-sg_main = 'I'.
    ass-sg_addy = space.
    ass-op_main = 'OBJECTKEY1'.
    APPEND ass TO restrict-ass_tab.
					
* Restricting the connid 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_connid'.
    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
            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.

<REMOVED BY MODERATOR>

Jay

Edited by: Alvaro Tejada Galindo on Feb 18, 2008 5:44 PM

8 REPLIES 8
Read only

Former Member
0 Likes
883

Hi,

Use the addition NO INTERVALS & NO-EXTENSION for that particular select-options.

Rgds,

Bujji

Read only

Former Member
0 Likes
883

Hello Jay,

Check this sample:


INITIALIZATION.
  PERFORM restrictions.
*&---------------------------------------------------------------------*
*&      Form  restrictions
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM restrictions.

  DATA: l_wa_opt_list TYPE sscr_opt_list,     "TYPE-POOLS: SSCR
        l_wa_ass      TYPE sscr_ass.

  DATA: l_it_restrict TYPE sscr_restrict.

* Für die Selektions-Optionen 'SO_DO_FL' und 'SO_DO_FH' nur
* Einzelwerte zulassen:
* Realisierung: SIGN = 'I' AND OPTION = 'EQ'.
  l_wa_opt_list-name = 'Schema_IEQ'.
  MOVE 'X' TO l_wa_opt_list-options-eq.     "nur OPTION 'EQ' erlaubt
  APPEND l_wa_opt_list TO l_it_restrict-opt_list_tab.

  MOVE: 'S'          TO l_wa_ass-kind,
        'SO_DO_FL'   TO l_wa_ass-name,
        '*'          TO l_wa_ass-sg_main,    "SIGN 'I' und 'E' erlaubt
        ' '          TO l_wa_ass-sg_addy,    "wie MAIN
        'Schema_IEQ' TO l_wa_ass-op_main,
        'Schema_IEQ' TO l_wa_ass-op_addy.
  APPEND l_wa_ass TO l_it_restrict-ass_tab.
  MOVE: 'SO_DO_FH'   TO l_wa_ass-name.
  APPEND l_wa_ass TO l_it_restrict-ass_tab.

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

  CHECK sy-subrc <> 0.
* Auch dieser Bursche schmeißt mit Exceptions ohne Meldungen um sich!
* Daher...
  MESSAGE e001(wod1) WITH sy-subrc 'SELECT_OPTIONS_RESTRICT'.
* Fehler >&1< beim Aufruf des Funktionsbausteines &2.

*  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDFORM.                    " restrictions

Hope this will help you,

Cheers,

Vasanth

Read only

0 Likes
883

Hi Vasanth.

I want to assign this logic for particular field,where i need to declare my fields.

Regards.

Jay

Read only

0 Likes
883

Hi,

Write like this.

>tables: spfli.

>

>select-options s_carrid for spfli-carrid no intervals no-extension..

*In the exaple code *


REPORT ZDANY_RESTRICT_SELECTION.

Include type pool SSCR
TYPE-POOLS sscr.
TABLES : sflight.

* defining the selection-screen
*select-options :*
*s_carrid for sflight-carrid no intervals  no-extension,*
*s_connid for sflight-connid no intervals  no-extension.*

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 carrid 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_carrid'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY1'.
APPEND ass TO restrict-ass_tab.

Restricting the connid 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_connid'.
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
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.

<REMOVED BY MODERATOR>

Mahi.

Edited by: Alvaro Tejada Galindo on Feb 18, 2008 5:45 PM

Read only

0 Likes
883

Hi Jay,

Pass the field name here


  move: 'S'       to ass-kind,
        'S_POSID' to ass-name,
        'I'       to ass-sg_main,
        ' '       to ass-sg_addy,
        'NO_INT'  to ass-op_main,
        'NO_INT'  to ass-op_addy.
  append ass to restrict-ass_tab.

  call function 'SELECT_OPTIONS_RESTRICT'
    exporting
*   PROGRAM                      =
      restriction                  = 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
            .

" You need to declare the field in the SELECT-OPTIONS

Cheers,

Vasanth

Read only

0 Likes
883

Hi Jay,

Pass the field name here


  move: 'S'       to ass-kind,
        'S_POSID' to ass-name,
        'I'       to ass-sg_main,
        ' '       to ass-sg_addy,
        'NO_INT'  to ass-op_main,
        'NO_INT'  to ass-op_addy.
  append ass to restrict-ass_tab.

  call function 'SELECT_OPTIONS_RESTRICT'
    exporting
*   PROGRAM                      =
      restriction                  = 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
            .

" You need to declare the field in the SELECT-OPTIONS

Cheers,

Vasanth

Read only

Former Member
0 Likes
883

Hi ,

use select-options x fro datatype no-extension

Regards

Neetesh

Read only

Former Member
0 Likes
883

Rest seem to be okay in the code apart from using convention. Check below


    ass-kind = 'S'.
    ass-name = 'S_carrid'.
    ass-sg_main = 'I'.
    ass-sg_addy = space.
    ass-op_main = 'OBJECTKEY1'.
    APPEND ass TO restrict-ass_tab.

Now when you are specifying the NAME it should be in bold letters, so S_CARRID & S_CONNID instead of S_carrid & S_connid. Above should be changed as:


    ass-kind = 'S'.
    ass-name = 'S_CARRID'.
    ass-sg_main = 'I'.
    ass-sg_addy = space.
    ass-op_main = 'OBJECTKEY1'.
    APPEND ass TO restrict-ass_tab.

Regards

Eswae