Ansicht
Dokumentation

SELECT_OPTIONS_RESTRICT - Make use of SELECT-OPTIONS easier on the selection screen

SELECT_OPTIONS_RESTRICT - Make use of SELECT-OPTIONS easier on the selection screen

CL_GUI_FRONTEND_SERVICES - Frontend Services   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module simplifies the handling of SELECT-OPTIONS on the selection screen by restricting possible selection options and signs.

By calling this function module, you can restrict the number of selectio options available for the chosen selection field. You can also disable the function allowing users to enter values to be excluded from the selection (SIGN = 'E').

The set of options (and signs) listed here can be extended for the 'multiple selection' screen.

You may call this function module once only in any program containing selection screens (if you try to call it a second time, the exception REPEATED occurs). This means that if a selection field appears on two different selection screens, you cannot set different restrictions for it each time. You can call the function module before the first selection screen is displayed (and even before the program is loaded). The latest you can call it is in the PBO of the first selection screen to be displayed. If you call it any later, the exception TOO_LATE occurs.

For a SUBMIT (standard selection screen 1000), the best time to call the function module is in the INITIALIZATION event. In this case, the report usually runs with a logical database. Both the logical database and the report itself can define restrictions (you can recognize this from the value of the DB parameter). The logical database can only set restrictions for its own (database-specific) selection criteria. The report, on the other hand, can restrict both its own selection criteria and those of the report. Only options allowed by both the logical database and the report are valid for the database-specific selection criteria.

If you call the function module from the logical database, the call must occur before the PBO of the first selection screen of the report: The most sensible way to to do this is in the INIT routine, which is processed both in a SUBMIT and when you call the selection screens of the report independently with CALL SELECTION-SCREEN. As in the report, you can only call the function module once from a logical database.

You pass the following in the RESTRICTION parameter (type SCR_RESTRICT, defined in type pool SSCR):

Component OPT_LIST_TAB:
This is a table of option lists.
Each line contains a field NAME (10 characters) with a
freely-definable name for a list of valid options, and a
field OPTIONS (structure RSOPTIONS), with a character field
of length 1 (for exmample, EQ, BT, ...) foro each of the 10
possible options. The options you select are valid.

Component ASS_TAB:
This is a table in which you assign selection screen objects to
option lists and permitted signs.
In each line, you must specify:
KIND: 'A': The restrictions apply to all SELECT-OPTIONS.
If you call the function module through the logical
database, only the database-specific SELECT-OPTIONS
are affected. If you call it through the program, the
restrictions apply to all SELECT-OPTIONS.
'B': Block on the selection screen. The restrictions apply
to all SELECT-OPTIONS within the selection screen block
specified in the field NAME (database-specific block
if you call the function module through the logical
database). The restrictions also apply to blocks within
the specified block.
'S': The restrictions apply to the single SELECT-OPTIONS
specified in NAME (database-specific field if you call
the function module through the logical database).
NAME: Where KIND = 'B' or 'S': Name of the object
Where KIND = 'A': Empty
SG_MAIN: '*': Do not restrict the sign on the main selection
screen.
'I': Only sign 'I' allowed on the main selection screen.
SG_ADDY: '*': Do not restrict the sign on the 'Multiple selection'
screen.
' ': Apply the same sign restriction to the multiple
selection screen as to the main selection screen.
'N': Multiple selections not allowed.
OP_MAIN: Name of the option list (from RESTRICTION-OPT_LIST_TAB)
for the main selection screen.
OP_ADDY: Name of the option list (from RESTRICTION-OPT_LIST_TAB)
for the multiple selection screen.
There are always at least as many options available on
the multiple selection screen as on the main selection
screen. The options available on the multiple selection
screen are the union of the two lists OP_MAIN and OP_ADDY.

The function module allows you to set 'progressive' restrictions. For example, you set restrictions with KIND = 'A', which are then overwritten for a block KIND = 'B' (the first set of restrictions no longer apply to the block). You can also apply further 'B' restrictions to blocks within the block. Finally, you can set individual restrictions for each selection option (whether it is part of a block or not).

Effect at runtime

On the selection screen, only the specified selection fields and (if set) only the sign 'I' are permitted. If you exclude the options 'BT' (interval) and 'NB' (exclude interval), the HIGH field of the selection criterion is deactivated.

Similarly, the 'Multiple selection' screen only permits the specified options and sign.If the field 'SG_ADDY' has the value 'N' (no multiple selections allowed), the multiple selection pushbutton is not displayed.This corresponds to the statuic 'NO-EXTENSION' addition in the SELECT-OPTIONS statement. If intervals are not allowed on the main selection screen, the 'to' text and the 'HIGH' field are not displayed.

Since more is usually allowed with 'multiple selections' than on the main selection screen, it is possible that a user may enter a selection on the multiple selection screen that is not allowed on the main selectiion screen. In this case, the main selection screen displays the first valid line. If none of the lines from the multiple selection screen are valid on the main selection screen, it remains empty, but the 'multiple selection arrow' at the end of the line turns green to indicate that selections have been made.

If selections exist that are not valid on either the 'main selection screen' or on the 'multiple selection screen' (for example, due to an obsolete variant), a runtime error occurs.

Example

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.

...

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.

Notes

You should take care when using this function module, since inconsistencies can arise if you use it with the 'NO INTERVALS' or 'NO-EXTENSION' additions.

The problem may also occur that the HIGH field for a selection field is not displayed (so no intervals can be entered). However, if you have used this function module to specify that only intervals are allowed for that particular selection field (only 'BT' and 'NB'), no entry at all is possible. In this case, the LOW field is deactivated as well.

When you call the report, you should also remember that the logical database may already have defined restrictions for its SELECT-OPTIONS. Since the system allows only those options allowed by both the logical database and the program, a situation can occur where the 'SELOPT_WITHOUT_OPTIONS' exception occurs.

Exceptions

If an exception occurs when you call the function module through the logical database, the database-specific restrictions are ignored, but any report-specific restrictions are retained.

If an exception occurs when you call the function module through the report, any database-specific restrictions are retained, but report-specific restrictions are ignored.

Restrictions are never activated in a call that ends in an exception.





Parameters

DB
PROGRAM
RESTRICTION

Exceptions

EMPTY_OPTION_LIST
INVALID_KIND
INVALID_SIGN
REPEATED
REPEATED_KIND_A
SELOPT_WITHOUT_OPTIONS
SELOPT_WITHOUT_SIGNS
TOO_LATE

Function Group

SLDB

RFUMSV00 - Advance Return for Tax on Sales/Purchases   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 16143 Date: 20240523 Time: 103741     sap01-206 ( 230 ms )