Application Development 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: 

What are Ranges? What is diff bet Ranges and Select options

Former Member
0 Kudos

What are Ranges?

What is the diff between Ranges and Select Options?

Can Any one plz explain me abt this....

Have a great day!

Thanks & Regards,

Krishna Chaitanya

5 REPLIES 5

Former Member
0 Kudos

Hi,

Here both SELECT-OPTIONS & RANGES works for the same purpose. They both are used for the range selection from selection screen. The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.

Eg. to SELECT-OPTIONS :

-


REPORT YARSELECT.

TABLES YTXLFA1.

SELECT-OPTIONS : VENDOR FOR YTXLFA1-LIFNR.

INITIALIZATION.

VENDOR-LOW = 1000. " It specifies the range starting value.

VENDOR-HIGH = 2000. " It specifies the range ending value.

VENDOR-OPTION = 'BT'. " specifies ranges value is in between.

VENDOR-SIGN = 'I'. "specifies both inclussive.

APPEND VENDOR.

- - - -

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Eg. to RANGES:

-


REPORT YARRANGE.

TABLES YTXLFA1.

RANGES: VENDOR FOR YTXFLA1-LIFNR.

- - - -

- - - --

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Here with RANGES user has to design an internal table with fields -

SIGN,OPTION,LOW and HIGH EXPLICITLY.

rgds,

bharat.

Former Member
0 Kudos

Hi,

What are the difference between SELECT-OPTIONS & RANGES?

Here both SELECT-OPTIONS & RANGES works for the same purpose. They both are used for the range selection from selection screen. The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.

Eg. to SELECT-OPTIONS :

-


REPORT YARSELECT.

TABLES YTXLFA1.

SELECT-OPTIONS : VENDOR FOR YTXLFA1-LIFNR.

INITIALIZATION.

VENDOR-LOW = 1000. " It specifies the range starting value.

VENDOR-HIGH = 2000. " It specifies the range ending value.

VENDOR-OPTION = 'BT'. " specifies ranges value is in between.

VENDOR-SIGN = 'I'. "specifies both inclussive.

APPEND VENDOR.

- - - -

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Eg. to RANGES:

-


REPORT YARRANGE.

TABLES YTXLFA1.

RANGES: VENDOR FOR YTXFLA1-LIFNR.

- - - -

- - - --

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Here with RANGES user has to design an internal table with fields -

SIGN,OPTION,LOW and HIGH EXPLICITLY.

-


>

Example:

select-options: bukrs for zstock-bukrs.

Should the user fill in 'ABFI' in BUKRS on the selection screen, BUKRS will look like this:

IEQABFI

This is because BUKRS is set as a table as follows:

begin of bukrs occurs 0,

SIGN(1) type c,

OPTION(2) type c,

LOW like bukrs,

HIGH like bukrs,

end of bukrs.

Now, when you create the following range, it will have the exact same fields set inside its table:

Ranges: bukrs for zstock-bukrs.

The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself, meaning you will have to fill bukrs-sign, bukrs-option, bukrs-low & bukrs-high all manually.

Some tips:

Sign is always I (for Include) or E (for Exclude)

Option can be a whole range, which includes:

EQ (Equal)

BT (Between))

CP (Contain Pattern)

So let's say you want to have the range check for all company codes not starting with AB, you will set your code as follow:

ranges: bukrs for zstock-bukrs.

bukrs-sign = 'E'. "Exclude

bukrs-option = 'CP'. "Pattern

bukrs-low = 'AB*'. "Low Value

bukrs-high = ''. "High Value

append bukrs.

Always remember to APPEND your range when you fill it, as the WHERE clause checks against the lines of the range table, not against the header line.

Hope this explains it well enough.

-


>

What does SIGN "I" & "E" mean?

The "I" stands for Include, and the "E" for Exclude.

The easiest way to learn how the range selections work is, create the following dummy program:

report dummy.

tables: mara.

select-options: matnr for mara-matnr.

start-of-selection.

loop at matnr.

write: / matnr-sign,

matnr-option,

matnr-low,

matnr-high.

endloop.

Run this program, and fill in a lot of junk into MATNR. Fill in some includes, some excludes, some ranges, etc., and you will soon realise how the system builds ranges (select-options). Once you know that, you can fill your own ranges quickly and efficiently.

Thanks&regards,

Sravani

Former Member
0 Kudos

Hi,

What are the difference between SELECT-OPTIONS & RANGES?

Here both SELECT-OPTIONS & RANGES works for the same purpose. They both are used for the range selection from selection screen. The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.

Eg. to SELECT-OPTIONS :

-


REPORT YARSELECT.

TABLES YTXLFA1.

SELECT-OPTIONS : VENDOR FOR YTXLFA1-LIFNR.

INITIALIZATION.

VENDOR-LOW = 1000. " It specifies the range starting value.

VENDOR-HIGH = 2000. " It specifies the range ending value.

VENDOR-OPTION = 'BT'. " specifies ranges value is in between.

VENDOR-SIGN = 'I'. "specifies both inclussive.

APPEND VENDOR.

- - - -

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Eg. to RANGES:

-


REPORT YARRANGE.

TABLES YTXLFA1.

RANGES: VENDOR FOR YTXFLA1-LIFNR.

- - - -

- - - --

- - - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Here with RANGES user has to design an internal table with fields -

SIGN,OPTION,LOW and HIGH EXPLICITLY.

-


>

Example:

select-options: bukrs for zstock-bukrs.

Should the user fill in 'ABFI' in BUKRS on the selection screen, BUKRS will look like this:

IEQABFI

This is because BUKRS is set as a table as follows:

begin of bukrs occurs 0,

SIGN(1) type c,

OPTION(2) type c,

LOW like bukrs,

HIGH like bukrs,

end of bukrs.

Now, when you create the following range, it will have the exact same fields set inside its table:

Ranges: bukrs for zstock-bukrs.

The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself, meaning you will have to fill bukrs-sign, bukrs-option, bukrs-low & bukrs-high all manually.

Some tips:

Sign is always I (for Include) or E (for Exclude)

Option can be a whole range, which includes:

EQ (Equal)

BT (Between))

CP (Contain Pattern)

So let's say you want to have the range check for all company codes not starting with AB, you will set your code as follow:

ranges: bukrs for zstock-bukrs.

bukrs-sign = 'E'. "Exclude

bukrs-option = 'CP'. "Pattern

bukrs-low = 'AB*'. "Low Value

bukrs-high = ''. "High Value

append bukrs.

Always remember to APPEND your range when you fill it, as the WHERE clause checks against the lines of the range table, not against the header line.

Hope this explains it well enough.

-


>

What does SIGN "I" & "E" mean?

The "I" stands for Include, and the "E" for Exclude.

The easiest way to learn how the range selections work is, create the following dummy program:

report dummy.

tables: mara.

select-options: matnr for mara-matnr.

start-of-selection.

loop at matnr.

write: / matnr-sign,

matnr-option,

matnr-low,

matnr-high.

endloop.

Run this program, and fill in a lot of junk into MATNR. Fill in some includes, some excludes, some ranges, etc., and you will soon realise how the system builds ranges (select-options). Once you know that, you can fill your own ranges quickly and efficiently.

Thanks&regards,

Sravani

Former Member
0 Kudos

check if this can help

You use the statement

SELECT-OPTIONS <seltab> for <f>.

to declare a selection table in the program that is linked to the <f> column of a database table, or to an internal <f> field in the program. A selection table is an internal table object of the standard table type that has a standard key and a header line. Selection tables are used to store complex selections using a standardized procedure. They can be used in several ways. Their main purpose is to directly translate the selection criteria into database selections using the WHERE addition in Open SQL statements.

In addition to selection tables that you create using SELECT-OPTIONS, you can use the RANGES statement to create internal tables that have the structure of selection tables. You can use these tables with certain restrictions the same way you use actual selection tables.

Structure of Selection Tables

The row type of a selection table is a structure that consists of four components: SIGN, OPTION, LOW, and HIGH. Each row of a selection table that contains values represents a sub-condition for the complete selection criterion. Description of the individual components:

SIGN

The data type of SIGN is C with length 1. The contents of SIGN determine for each row whether the result of the row condition is to be included in or excluded from the resulting set of all rows. Possible values are I and E.

– I stands for "inclusive" (inclusion criterion - operators are not inverted)

– E stands for "exclusive" (exclusion criterion - operators are inverted)

OPTION

The data type of OPTION is C with length 2. OPTION contains the selection operator. The following operators are available:

– If HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions. Yet operators CP and NP do not have the full functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*' or '+' ) are used in the input fields. If wildcards are entered on the selection screen, the system automatically uses the operator CP. The escape character is defined as #.

– If HIGH is filled, you can use BT (BeTween) and NB (Not Between). These operators correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to a range. You cannot use wildcard characters.

LOW

The data type of LOW is the same as the column type of the database table, to which the selection criterion is linked.

– If HIGH is empty, the contents of LOW define a single field comparison. In combination with the operator in OPTION, it specifies a condition for the database selection.

– If HIGH is filled, the contents of LOW and HIGH specify the upper and lower limits for a range. In combination with the operator in OPTION, the range specifies a condition for the database selection.

HIGH

The data type of HIGH is the same as the column type of the database table, to which the selection criterion is linked. The contents of HIGH specify the upper limit for a range selection.

If the selection table contains more than one row, the system applies the following rules when creating the complete selection criterion:

Form the union of sets defined on the rows that have SIGN field equal to I (inclusion).

Subtract the union of sets defined on the rows that have SIGN field equal to E (exclusion).

If the selection table consists only of rows in which the SIGN field equals E, the system selects all data outside the set specified in the rows.

RANGES tables

You can use the following variants of the TYPES and DATA statements to create internal tables of the same type as selection tables.

TYPES|DATA <rangetab> TYPE RANGE OF <type>.

or

TYPES|DATA <rangetab> LIKE RANGE OF <obj>.

This defines internal standard tables whose line type is a structure as follows:

SIGN(1) TYPE C

OPTION(2) TYPE C

LOW TYPE <type> bzw. LIKE <obj>

HIGH TYPE <type> bzw. LIKE <obj>

You can also use the RANGES statement to create internal tables of the same type as selection tables.

RANGES <rangetab> FOR <f>.

This statement is simply a shortened form of the following statements:

DATA: BEGIN OF <rangetab> OCCURS 0,

sign(1) TYPE c,

option(2) TYPE c,

low LIKE <f>,

high LIKE <f>,

END OF <rangetab>.

Because the statement represents an obsolete form of defining internal tables with headers and headers should not to be used, you should use above variants of TYPES and DATA statements instead of RANGES.

Tables defined in this way have the same structure as selection tables, but they do not have the same functionality. They are not part of the selection screen: No corresponding input fields are generated and these tables cannot be used as a data interface in a program <prog> called using

SUBMIT <prog> WITH <rangetab> IN <table>.

. However, you can use the above statements to create the table <table> in the calling program. The main function of these tables is to pass data to the actual selection tables without displaying the selection screen when executable programs are called.

The above tables are like actual selection tables in the WHERE clause of Open SQL statements and can be used in combination with the IN operator in logical expressions, but they are not linked to a database table. They:

are not passed like selection criteria to logical databases

cannot be used with the shortened form of selection tables in logical expressions

cannot be used like selection criteria in GET events

Obsolete version:

REPORT demo_sel_screen_tables_ranges.

RANGES s_carrid1 FOR spfli-carrid.

s_carrid1-sign = 'I'.

s_carrid1-option = 'EQ'.

s_carrid1-low = 'LH'.

APPEND s_carrid1.

SUBMIT demo_selection_screen_ldb_1 WITH carrid IN s_carrid1

VIA SELECTION-SCREEN AND RETURN.

Korrekte Version:

REPORT demo_sel_screen_tables_ranges.

DATA: s_carrid2 TYPE RANGE OF spfli-carrid,

s_carrid2_wa LIKE LINE OF s_carrid2.

s_carrid2_wa-sign = 'I'.

s_carrid2_wa-option = 'EQ'.

s_carrid2_wa-low = 'AA'.

APPEND s_carrid2_wa TO s_carrid2.

SUBMIT demo_selection_screen_ldb_1 WITH carrid IN s_carrid2

VIA SELECTION-SCREEN AND RETURN.

A selection table S_CARRID is created with reference to column CARRID of database table SPFLI. Fields S_CARRID-LOW and S_CARRID-HIGH have the same type as CARRID. The work area of the internal table S_CARRID is filled and appended to the table. Program DEMO2 is called. If DEMO2 is linked to logical database F1S, its selections screen contains the fields of selection criterion CARRID from the logical database. These fields are filled with the contents of the internal table.

Former Member
0 Kudos

Hello Sravani yendru & Bharat Kalagara.

Thank you for your response.

Information that you have provided was helpful.

Points are rewarded.

Have a great day!

Regards,

Krishna Chaitanya