Select Options - Syntax & Examples (SAP ABAP Keyword)


INTRODUCTION:

- The SELECT-OPTIONS statement creates selection criteria for a particular database field. The existence of the statement in the code causes the selection screen to display at the beginning of the report execution. It creates a line on the selection screen where the user can enter selection criteria for that field.

- Basically SELECT-OPTIONS statement determines the user interface for any report program.


SYNTAX:

SELECT-OPTIONS <sel> FOR <f>
                                  [DEFAULT <g> [TO <h>]  [OPTION <op>] SIGN <s>]
                                  [MEMORY ID <pid>]
                                  [LOWER CASE]
                                  [OBLIGATORY]
                                  [NO-DISPLAY]
                                  [MODIF ID <key>]
                                  [NO-EXTENSION]
                                  [NO INTERVALS]
                                  [NO DATABASE SELECTION]

<sel> is the selection name that can have a max of 8 characters.

The above syntax declares a selection table <sel> for the field <f> and also places input fields on the corresponding selection screen.

- DEFAULT <g> - This optional allows to set a single value <g> as a default value.

- DEFAULT <g> TO <h> - This optional allows to set a range selection.

- DEFAULT <g> [TO <h>]  [OPTION <op>] - The additional OPTION basically defines the relational operator.

For single field comparisons, OPTION <op> can be EQ, NE, GE, GT, LE, LT, CP, or NP.
The default value is EQ.

For range selections, OPTION <op> can be BT (Between) or NB (Not In Between).
The default value is BT.


- DEFAULT <g> [TO <h>]  [OPTION <op>] SIGN <s> - The optional SIGN indicates whether the entry is Inclusive(I) or Exclusive (E).

The value of <s> can be I or E.
The default value is I.


- MEMORY ID <pid> - On the selection screen, the SET/GET ID <pid> is assigned to the left range limit of the selection criterion. Remember to specify the memory ID without quotation marks. It can be up to 3 characters long.


- LOWER CASE - This optional accepts input in lowercase.


- OBLIGATORY - This optional is used to make the an entry mandatory. Using this optional makes the user mandatory to enter a value for this selection (in the LOW field).


- NO-EXTENSION - This option restricts user to make entry in one line. When the NO-EXTENSION option is used, the user will not be able to see the pushbutton containing arrows pointing to the right at the far sight.


- NO INTERVALS - This option removes the 'to' field. It  means the selection option is displayed on the selection screen without a 'to' field.. The push button for calling the "Multiple Selection" screen appears immediately after the 'from' field.



EXAMPLES:


SELECT-OPTIONS: s_deldt FOR likp-erdat DEFAULT '20110101' TO '20110202'.
SELECT-OPTIONS: date FOR sy-datum DEFAULT sy-datum.





SELECT-OPTIONS: s_ernam FOR likp-ernam DEFAULT 'NAVEENT' SIGN E NO INTERVALS.




SELECT-OPTIONS: s_ernam FOR likp-ernam .




On pressing ENTER:




SELECT-OPTIONS: s_ernam FOR likp-ernam LOWER CASE.




SELECT-OPTIONS: s_deldt FOR likp-erdat OBLIGATORY.




SELECT-OPTIONS: s_ernam FOR likp-ernam NO INTERVALS.





SELECT-OPTIONS: s_ernam FOR likp-ernam NO-EXTENSION.




SELECT-OPTIONS: s_ernam FOR likp-ernam NO-EXTENSION NO INTERVALS.





SELECTION TABLE:


- SELECT-OPTIONS on the report program initial screen are a convenient way to enter simple or
complex selection criteria. The SELECT-OPTIONS statement creates a selection table which is basically an internal table that holds the selection criteria for that field.

- Selection criteria for each item on a selection screen are stored in a selection table. Selection tables are system generated internal tables that have the following standard field format:

SIGN:

-  It is either I or E, I means to include the found results, E excludes them.

- This field indicates whether the current row of the table is INCLUSIVE (I) or EXCLUSIVE (E). Each row of the internal table represents a particular condition (e.g. BETWEEN 1 & 5).

- The overall condition specified by the selection table is the union of lines marked with sign I (Inclusive), less the union of lines marked with sign E (Exclusive).

OPTION:

- This field holds the relational operator for the current row of the selection table (e.g. "NE" <>).

LOW:

- This field holds the low value for range comparisons. If the comparison is against a single value, this field contains that value.

HIGH:

- This field holds the high value for range comparisons (Only for "BT" option).

EXAMPLE:

I       BT       3        10
I       EQ      2
E      GE      8

The result set of the mentioned selection table is: 2, 3, 4, 5, 6, 7.


ALSO READ:

- ELEMENTARY DATA TYPES - Initial Values, Syntax & Properties.

- FIELD SYMBOLS - Introduction, Syntax & Examples.

- PARAMETERS - Introduction, Syntax & Examples.

- SELECT-OPTIONS - Introduction, Syntax & Examples.

- SELECTION-SCREEN - Introduction, Syntax & Examples.

- SSCRFIELDS - The Screen Fields Table.


Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.


tags: select options syntax in abap, sap abap select options internal table, select query for select-options in abap, select options with no intervals in abap, sap select options structure, select option in sap abap, select option abap, select options abap, sap select options, select option abap, abap select option, abap select options,