Está en la página 1de 5

Mdulo de funciones SELECT_OPTIONS_RESTRICT: Esta funcin permite restringir el nmero de opciones de seleccin disponibles para un campo de seleccin SELECT-OPTIONS

determinado. Tambin puede deshabilitarse, por ejemplo, la opcin de excluir valores. Estas limitaciones pueden extenderse a la pantalla de seleccin mltiple. Si ejecutamos el report con el cdigo de ejemplo propuesto en el help de SAP, vemos que define varias select-options, cada una con distinto comportamiento:

En la select-options SEL_0_0, se ha limitado los signos disponibles nicamente a la inclusin, (la exclusin est deshabilitada):

En las select-options SEL_0_2 y SEL_0_3 se ha limitado las opciones disponibles nicamente a la igualdad, y el signo a la inclusin:

Por otra parte, SEL_0_0 y la SEL_0_1 tampoco admiten rangos, slo valores individuales:

A continuacin, transcribo el cdigo que viene como ejemplo y que genera las select-options que acabo de detallar. Para utilizarlo en un report hay que copiar todas las definiciones y jugar con las opciones y signos que se aaden a la tabla RESTRICT-ASS_TAB como

restricciones para un select-options (o para todos los select-options incluidos en un bloque), hasta dar con las limitaciones que necesitemos. Y, finalmente, llamar a la funcin para surtan efecto las limitaciones definidas.
REPORT TESTREP. * Include type pool SSCR TYPE-POOLS SSCR. * Define the object to be passed to the RESTRICTION parameter DATA RESTRICT TYPE SSCR_RESTRICT. * Auxiliary objects for filling RESTRICT DATA OPT_LIST TYPE SSCR_OPT_LIST. DATA ASS TYPE SSCR_ASS. * Define the selection screen objects * First block: 3 SELECT-OPTIONS SELECTION-SCREEN BEGIN OF BLOCK BLOCK_0 WITH FRAME TITLE TEXT-BL0. SELECT-OPTIONS SEL_0_0 FOR SY-TVAR0. SELECT-OPTIONS SEL_0_1 FOR SY-TVAR1. SELECT-OPTIONS SEL_0_2 FOR SY-TVAR2. SELECT-OPTIONS SEL_0_3 FOR SY-TVAR3. SELECTION-SCREEN END OF BLOCK BLOCK_0. * Second block: 2 SELECT-OPTIONS SELECTION-SCREEN BEGIN OF BLOCK BLOCK_1 WITH FRAME TITLE TEXT-BL1. SELECT-OPTIONS SEL_1_0 FOR SY-SUBRC. SELECT-OPTIONS SEL_1_1 FOR SY-REPID. SELECTION-SCREEN END OF BLOCK BLOCK_1. INITIALIZATION. * Define the option list * ALL: All options allowed MOVE 'ALL' TO OPT_LIST-NAME. MOVE 'X' TO: OPT_LIST-OPTIONS-BT, OPT_LIST-OPTIONS-CP, OPT_LIST-OPTIONS-EQ, OPT_LIST-OPTIONS-GE, OPT_LIST-OPTIONS-GT, OPT_LIST-OPTIONS-LE, OPT_LIST-OPTIONS-LT, OPT_LIST-OPTIONS-NB, OPT_LIST-OPTIONS-NE, OPT_LIST-OPTIONS-NP. APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB. * NOPATTERN: CP and NP not allowed CLEAR OPT_LIST. MOVE 'NOPATTERN' TO OPT_LIST-NAME. MOVE 'X' TO: OPT_LIST-OPTIONS-BT, OPT_LIST-OPTIONS-EQ, OPT_LIST-OPTIONS-GE, OPT_LIST-OPTIONS-GT, OPT_LIST-OPTIONS-LE, OPT_LIST-OPTIONS-LT, OPT_LIST-OPTIONS-NB, OPT_LIST-OPTIONS-NE. APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB. * NOINTERVLS: BT and NB not allowed CLEAR OPT_LIST.

MOVE 'NOINTERVLS' TO OPT_LIST-NAME. MOVE 'X' TO: OPT_LIST-OPTIONS-CP, OPT_LIST-OPTIONS-EQ, OPT_LIST-OPTIONS-GE, OPT_LIST-OPTIONS-GT, OPT_LIST-OPTIONS-LE, OPT_LIST-OPTIONS-LT, OPT_LIST-OPTIONS-NE, OPT_LIST-OPTIONS-NP. APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB. * EQ_AND_CP: only EQ and CP allowed CLEAR OPT_LIST. MOVE 'EQ_AND_CP' TO OPT_LIST-NAME. MOVE 'X' TO: OPT_LIST-OPTIONS-CP, OPT_LIST-OPTIONS-EQ. APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB. * JUST_EQ: Only EQ allowed CLEAR OPT_LIST. MOVE 'JUST_EQ' TO OPT_LIST-NAME. MOVE 'X' TO OPT_LIST-OPTIONS-EQ. APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB. * Assign selection screen objects to option list and sign * KIND = 'A': applies to all SELECT-OPTIONS MOVE: 'A' TO ASS-KIND, '*' TO ASS-SG_MAIN, 'NOPATTERN' TO ASS-OP_MAIN, 'NOINTERVLS' TO ASS-OP_ADDY. APPEND ASS TO RESTRICT-ASS_TAB. * KIND = 'B': applies to all SELECT-OPTIONS in block BLOCK_0, * that is, SEL_0_0, SEL_0_1, SEL_0_2 CLEAR ASS. MOVE: 'B' TO ASS-KIND, 'BLOCK_0' TO ASS-NAME, 'I' TO ASS-SG_MAIN, '*' TO ASS-SG_ADDY, 'NOINTERVLS' TO ASS-OP_MAIN. APPEND ASS TO RESTRICT-ASS_TAB. * KIND = 'S': applies to SELECT-OPTION SEL-0-2 CLEAR ASS. MOVE: 'S' TO ASS-KIND, 'SEL_0_2' TO ASS-NAME, 'I' TO ASS-SG_MAIN, '*' TO ASS-SG_ADDY, 'EQ_AND_CP' TO ASS-OP_MAIN, 'ALL' TO ASS-OP_ADDY. APPEND ASS TO RESTRICT-ASS_TAB. * KIND = 'S': Applies to SELECT-OPTION SEL_0_3 CLEAR ASS. MOVE: 'S' TO ASS-KIND, 'SEL_0_3' TO ASS-NAME, 'I' TO ASS-SG_MAIN, 'N' TO ASS-SG_ADDY, 'JUST_EQ' TO ASS-OP_MAIN. APPEND ASS TO RESTRICT-ASS_TAB. * Call function module CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' EXPORTING RESTRICTION = RESTRICT

DB ='' EXCEPTIONS TOO_LATE =1 REPEATED =2 NOT_DURING_SUBMIT =3 DB_CALL_AFTER_REPORT_CALL = 4 SELOPT_WITHOUT_OPTIONS =5 SELOPT_WITHOUT_SIGNS =6 INVALID_SIGN =7 REPORT_CALL_AFTER_DB_ERROR = 8 EMPTY_OPTION_LIST =9 INVALID_KIND = 10 REPEATED_KIND_A = 11 OTHERS = 12.

* Exception handling IF SY-SUBRC NE 0. ... ENDIF. ... START-OF-SELECTION. ...

Adjunto tambin la explicacin provista con el ejemplo: There is an explicit assignment for SEL_0_2: On the main selection screen, only the options EQ and CP and the sign I are allowed, while on the multiple selection scren, all options (option list 'ALL') and both signs (SG_ADDY = '*') are allowed. There is also an explicit assignment for SELECT-OPTION SEL_0_3: Only the option EQ and the sign I is allowed on the main selection screen, and multiple selections are not allowed at all. The multiple selections pushbutton is not displayed. On the main selection screen, where intervals are not allowed, the 'to' text and the HIGH field are not displayed. Consequently, the selection criterion appears on the screen like a parameter. For the two other SELECT-OPTIONS in BLOCK_0, that is, SEL_0_0 and SEL_0_1, the restriction for BLOCK_0 applies: Only sign I, with no intervals on the main selection screen, and both signs, but still no intervals on the multiple selection screen. For all SELECT-OPTIONS not in block BLOCK_0, that is, SEL_1_0 and SEL_1_1, the restrictions defined for KIND = 'A' apply: No patterns on the main selection screen, but both signs are allowed. All options are allowed on the multiple selection screen (union of NOPATTERN and NOINTERVLS), and again, both signs.

También podría gustarte