‎2007 Aug 30 5:24 AM
hi all ,
What is the difference between Select-options and Ranges statement ::
tables: vbak,vbap.
select-options: s1 for vbak-vbeln.
ranges: s2 for vbap-posnr.
Now my question is how they behave differently S1 and S2. ???/
thanks
sarit
‎2007 Aug 30 5:28 AM
hi,
The 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.
The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself.
Reward points if helpful,
Regards,
jinesh.
‎2007 Aug 30 5:28 AM
hi,
The 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.
The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself.
Reward points if helpful,
Regards,
jinesh.
‎2007 Aug 30 5:29 AM
Hi Sarit,
Select-option is a Screen object.. When you code SELECT-OPTIONS in your program , a select option field is shown on the selection screen of the report.
Range is similar in the structure to select-option, but it is used internally in the program to do similar operations of comparison, data fetching etc..
Thanks and Best Regards,
Vikas Bittera.
**Reward if useful**
‎2007 Aug 30 5:30 AM
Hi
In both the cases a selection table is created with the fields, SIGN,OPTION,LOW and HIGH
but we use the select-options to take all the continuous values of data of that field
where as Ranges are used to populate some different non contiouous values of that field and used in the where condition.
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Aug 30 5:32 AM
hey u r s1 comes in selection screen..............but u r s2 will not visible in selection screen....
see the difference
select-options: ...
You use the SELECT-OPTIONS statement to declare selection tables and create corresponding input fields on the associated selection screen. You can modify the associated text as selection text. When the selection screen is processed, the values entered by the user into the input fields are assigned to the header line of the selection table and appended to the table. The position of the statement in the declaration part of the program determines the selection screen to which the input fields belong.
The basic form of the SELECT-OPTIONS statement is as follows:
SELECT-OPTIONS <seltab> FOR <f>.
It declares a selection criterion <seltab> that is linked to a field <f> that has already been declared locally in the program. The names of selection criteria are currently restricted to eight characters. Valid data types of <f> include all elementary ABAP types except data type F. You cannot use data type F, references and aggregate types. If you want to use the selection criterion to restrict database selections, it is a good idea to declare <f> with reference to a column of the corresponding database table. It then inherits all of the attributes of the data type already defined in the ABAP Dictionary. In particular, the field help (F1) and the possible entries help (F4) defined for these fields in the Dictionary are available to the user on the selection screen.
The selection table, which has the same name as the selection criterion, <seltab>, is usually filled by the user on the selection screen or by calling programs. You can also process the selection table like any other internal table in the program.
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>.
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
reward points if helpful....
Message was edited by:
raam
‎2007 Aug 30 5:54 AM
"Difference Between Select-Options & Ranges
'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.
<u>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.</u>
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.
reward points if it is usefull......
Girish
‎2007 Aug 30 6:12 AM
Hi,
The main difference is that when you submit any other report in your main program, you cant able to see the selection-screen of that you are submitting.there comes the real use of ranges.In other cases both will be same.
Performance wise select-options is prefarable.
regards,
praveen
‎2007 Aug 30 6:53 AM
HI
<u><b>RANGES</b></u> Obsolete declaration of a Ranges-table. This statement (not allowed in classes) is a short form of the following statement sequence which is also not allowed in classes:
<u><b>SELECT OPTIONS</b></u> 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.
YOU CAN REFER HERE
REWARD IF USEFULL
<b>SELECT-OPTIONS selcrit FOR {dobj|(name)}
[screen_options]
[value_options]
[ldb_options].</b>
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 special rules apply for entries on the selection screen.
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 entered, the selection option is automatically set to "CP". If "CP" is set, and all wildcard characters have been removed, the selection option is automatically set to "EQ" when there is a user action. This limitation does not apply within the program. During evaluation of the selection table, column low can also contain a string without wildcard characters for the selection options "CP" and "NP".
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. Each time before the selection screen is sent to the selection screen event ATSELECTION-SCREEN OUTPUT, the content of first row in the selection table is transported to the selection screen, with a conversion routine being executed if required. If the length of columns low and high in the first row of the selection table is over 45, the excessive content is cut off to the right. It is only possible for all rows to be transported if the button for multiple selections is selected. A conversion routine might be executed here, and rows might be cut off. Settings for the content of the input fields can be made in value_options.
After a user action on the selection screen, the contents of the input fields and the chosen settings are transported to the first row and the header row of the selection table.
After a user action on the dialog box for multiple selections, the contents of all input fields and the chosen settings are transported to the rows of the selection table, and the contents of the header are initialized. During these transports, the contents of character-type fields are converted by default into capitals, after which a conversion routine is performed, if required. After each transport, various selection screen events are triggered.
If a value has been entered in the entry field for the upper interval high, the system checks whether this value is greater than the lower interval limit low> following each transport and conversion routine (if performed). If necessary, an error message is sent. This check can be switched off before the selection screen is sent, using the function module
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.
If a selection criterion for data types is supplied with data when calling up an executable program with SUBMIT , a conversion routine may be performed for the first row, while the value of the columns low and high will be truncated to the right of position 45 for the first row. No conversion routine or truncation is performed for any other rows. If the selection criterion is declared with the addition NO-DISPLAY, no conversion routine or truncation will be performed for the first row either.
<b>RANGES rtab FOR dobj [OCCURS n].</b>
Obsolete declaration of a Ranges-table. This statement (not allowed in classes) is a short form of the following statement sequence which is also not allowed in classes:
DATA: BEGIN OF rtab OCCURS {10|n},
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low LIKE dobj,
high LIKE dobj,
END OF rtab.
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.
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).
‎2007 Aug 30 8:12 AM
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.