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

Diffrence between Select-options and Ranges

Former Member
0 Likes
928

Hi Experts,

Can anybody help me in what is the main difference between SELECT-OPTIONS and RANGES...

Thaks

KRISH

5 REPLIES 5
Read only

Former Member
0 Likes
829

Hi,

1) SELECT-OPTIONS will be displayed on the selection-screen.

RANGES will not be displayed on the selection-screen.

2) SELECT-OPTIONS can be used in logical database also..Which means you can filter the data in the GET statement using CHECK select-options name.

Thanks,

Naren

Read only

Former Member
0 Likes
829
Read only

Former Member
0 Likes
829

Hi,

Select-options are the normal select options that you define on Selection screen.

While Ranges are similar to Select options in the way it creates a internal table of the same form as that of Select-options. The internal table that is created has the fields

HIGH

LOW

SIGN

OPTION.

But the difference between Select-options and ranges are that we don't need to define the ranges in Selection screen. It is created by explicitly coding in the Program. (see Example below). And we can fill the internal table for ranges in the program code itself and then can use it in the same manner as we use Select-option of screen

Example: Here r_belnr is range while s_bukrs and s_gsber is Select-options.

Here i have defined a range and then filling it internally in the program coding and then using it in select query.

TYPES: ty_belnr TYPE RANGE OF bkpf-belnr.

DATA: r_belnr TYPE ty_belnr WITH HEADER LINE.

LOOP AT i_bkpf INTO wa_bkpf.

r_belnr-sign = 'I'.

r_belnr-option = 'EQ'.

r_belnr-low = wa_bkpf-belnr.

APPEND r_belnr.

ENDLOOP.

CLEAR r_belnr.

SELECT belnr

aufnr

FROM bseg

INTO TABLE i_bseg

FOR ALL ENTRIES IN i_aufk

WHERE bukrs IN s_bukrs

AND belnr IN r_belnr

AND gjahr EQ p_gjahr

AND gsber IN s_gsber

AND aufnr EQ i_aufk-aufnr.

Hope now u have got the difference between Select-options and ranges. Get back to me if u still ahve doubts.

~~Guduri

Read only

Former Member
0 Likes
829

Hello,

A select-options variable can be used to store selection criteria, just like one defined with ranges.

If the variable is defined as select-options it will also appear in the selection screen when the program runs. Therefore the selection criteria values can be saved in a variant.

ranges is obsolete.

See the documentation below copied from the on-line help.

Best regards... Lucio

-


RANGES

Syntax

RANGES rtab FOR dobj [OCCURS n].

Effect

Obsolete declaration of a Ranges-table. This statement (not allowed in classes) is a short form of the following statement sequence:

DATA: BEGIN OF rtab OCCURS {10|n},

sign(1) TYPE c,

option(2) TYPE c,

low LIKE dobj,

high LIKE dobj,

END OF sel.

An internal table rtab with the structure of a selection table and a header line is declared. Without the addition OCCURS, the initial memory requirement (see DATA - ranges-tables) of the ranges-table is set to ten rows. With the addition OCCURS, you can specify a numeric literal or a numeric constant n to determine a different initial memory requirement.

Note

It is not allowed to declare internal tables with header lines. Due to this, the statement RANGES is not allowed in header lines. To declare a ranges-table in classes, you can use the addition TYPE|LIKE RANGE OF (see TYPES - ranges-table type and DATA - ranges-tables).

-


SELECT-OPTIONS

Syntax

SELECT-OPTIONS selcrit

FOR {dobj|(name)}

[ screen_options]

[ value_options]

[ldb_options].

Effect

This declares a selection criterion selcrit for a data object dobj or a type specified in name. Selection criteria are components of a selection screen, to which are assigned a selection table in the ABAP program, as well as two input fields and a pushbutton for multiple selection.

The name of the selection criterion selcrit is limited to a maximum of 8 characters. This statement is allowed in the global declaration part of executable programs, function groups and module-pools. In function groups and module-pools it is only allowed within the definition of an independent selection screen. In executable programs it is otherwise automatically assigned to the standard selection screen.

The statement SELECT-OPTIONS has the following effect:

The statement declares a selection table in the program with the name selcrit. A selection table is an internal standard table with header line and standard key. In selection tables, you can save multiple logical conditions . The content of selection screens can be analyzed in a logical expression and in the expression of a WHERE-condition in Open SQL. Selection tables have the following four columns:

sign of type c and length 1. The content of sign determines for every row whether the result of the condition formulated in the column is included or excluded in the entire resulting set for all rows. Evaluable values are "I" for include and "E" for exclude.

option of type c and length 2. option contains the selection option for the condition of the row in form of logical operators. Analyzable operators are "EQ", "NE", "GE", "GT", "LE", "LT", "CP" and "NP" if column high is initial, and "BT", "NB" if column high is not initial. With the options "CP" and "NP", the data type of the columns low and high must be of the data type c, and low must contain at least one wildcard character "" or "*", in which "" masks a single character and "*" a user-defined, even empty, character chain.

low of the data type defined after FOR. This column is designated for the comparison value or the lower interval limitation.

high of the data type defined after FOR. This column is designated for the upper interval limitation.

Two input fields with the name selscrit-low and selscrit-high are created on the current selection screen using a matching external data type in a new line at positions 35 and 60. The length of the input fields bases upon the length of the data type which is defined after FOR. The maximum length of the input fields is 45. The maximum visible length of the input fields is, depending on the nesting depth, in blocks with frames between 10 and 18. If the length is larger than the maximum visible length, then the content is scrollable.

Before the first input field, an automatically generated output field

is displayed as identifier in the first possible position, whose length is, depending on the nesting depth, in blocks with frames between 20 and 30. The output field either contains the name of the selection criterion selcrit, or the selection text which is assigned to the selection criterion in the text elements of the program. If the user requests a field- or input-help on the output field using the function key F1 resp. F4, the same output is displayed as if one of the input fields is chosen.

A pushbutton multiple selection is created after the second input field. If you select this pushbutton, a dialog screen with four tabstrip control pages appears, in which the input fields are again displayed in tabular form in Table Controls. The tabstrip pages are separated based on individual value comparison, interval limitation, and settings for the column sign.

As a user, you can select an input field with a double-click on the selection screen or use the dialog screen for multiple selection. On the selection screen, you can also choose the value for column sign. On the dialog screen for multiple selection, you can do this by selecting the respective tabstrip page. If the selection option is not equal to "EQ" or "BT", then it is displayed as an icon in front of the first input field. The color of the icon is green if the content of column sign is "I", and red if it is "E".

The selection options "CP" and "NP" can be selected only if the first input field contains one of the wildcard characters "*" or "+". If one of these characters is specified, the selection option is automatically set to "CP" when there is a user action.

The attributes of the elements on the selection screen can be influenced with the statement screen_options or the statement SELECTION-SCREEN.

The first row of the selection table selcrit is linked with the input fields on the selection screen. All rows are displayed in the dialog box for multiple selection. Before sending the selection screen, the content of the selection table is transported to the selection screen and displayed in the corresponding location. If the length of columns low and high in the first row of the selection table is larger than 45, then the excessive content is cut off to the right. In remaining rows excessive content is only cut off if the dialog box for multiple selection is displayed. After an user action on the selection screen or in the dialog box for multiple selections, the content of the input fields and the selected settings are transported into the internal table, whereby several events are raised. In doing so, the content of character type fields is converted into upper case by default. All setting regarding the content of the input field can be done in value_options.

If selection criteria are defined in the selection-include of a logical database, further additions ldb_options are necessary resp. possible.

If in an executable program, a selection criterion is defined for a component of a node of the linked logical database, declared by TABLES or NODES, and the node in question is intended for free selection on the logical database, then the selection table is transferred to the logical database after selection screen processing and is treated there as a free selection. Furthermore, in this case, the input fields for the corresponding free selection are displayed directly on the selection screen, without the necessity for the user having to select them via the function free selection.

Note

If a selection criterion for data types is supplied with a length greater than 45 when calling an executable program with SUBMIT, the value of columns low and high in the first row of the selection table are then truncated to the right of position 45. The remaining rows are not truncated. The first row is also not truncated if the selection criterion is declared with the NO-DISPLAY addition.

Read only

Former Member
0 Likes
829

Hi,

As everyone says SELECT-OPTIONS is for selection-screen, and one more thing is you can have it displayed with or without extensions and intervals, you can assign a MODIF ID and manipulate its properties.

Whereas, Ranges behaves similar to select-options but user has to create this inside their code.

Simple and sweet.

Regards

Subramanian