‎2008 Mar 05 3:24 PM
‎2008 Mar 05 3:33 PM
Hi,
Please refer to the docu below, direct extract from ABAPDOCU
RANGES
Basic form
RANGES sel FOR f.
Addition:
... OCCURS n
This statement is not allowed in an ABAP Objects context. See Prohibit RANGES.
Effect
Defines an internal table similar to a selection
criterion sel defined using the SELECT-OPTIONS sel FOR f statement.
The above statement is identical to:
DATA: BEGIN OF sel OCCURS 10,
SIGN(1),
OPTION(2),
LOW LIKE f,
HIGH LIKE f,
END OF sel.
Note
If you use the IN operator in conjunction with SUBMIT, CHECK, IF, WHILE or SELECT, always define the associated internal table using SELECT-OPTIONS or RANGES (never directly).
Addition
... OCCURS n
Effect
Changes the OCCURS value 10 to the value of occ.
Thanks,
Sriram Ponna.
‎2008 Mar 05 3:28 PM
Check this
Basic form RANGES sel FOR f.
Addition:*
... OCCURS n
This statement is not allowed in an ABAP Objects context. See
RANGES not allowed.
Effect* Defines an internal table similar to a selection criterion sel
defined using the SELECT-OPTIONS sel FOR f statement.
The above statement is identical to:
DATA: BEGIN OF sel OCCURS 10,
SIGN(1),
OPTION(2),
LOW LIKE f,
HIGH LIKE f,
END OF sel.
Note If you use the IN operator in conjunction with SUBMIT, CHECK,
IF, WHILE or SELECT, always define the associated internal
table using SELECT-OPTIONS or RANGES (never directly).
Addition ... OCCURS n
Effect Changes the OCCURS value 10 to the value of n.
‎2008 Mar 05 3:28 PM
Ranges are similar to select-options which are declared in screen ,
except that these are not shown in the screen.
Ranges have the structure with fields ..
sign
option
low
high
‎2008 Mar 05 3:29 PM
Hi Nagaraj,
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 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.
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).
<REMOVED BY MODERATOR>
Regards,
Venkat
Edited by: Alvaro Tejada Galindo on Mar 5, 2008 5:50 PM
‎2008 Mar 05 3:31 PM
ASSIGN feld1 TO <fs> RANGE feld2.
This addition explicitly sets the range limits, making it possible to define addresses past field limits, for example to edit repeating groups with the ASSIGN INCREMENT statement.
The field limits of field2 are used as the range for <fs>.
In a UP, the limits specified by the RANGE definition must include the range limits that would otherwise result from the rules described above.
If the memory area of field1 is not completely contained in field2, there is a catchable runtime error.
Field field2, which defines the range, may also be deep. Repeating groups with deep types therefore can also be processed.
ASSIGN feld INCREMENT n TO <fs>.
The field symbol is incremented by n times the length of field, starting with the position defined by field.
First the range for the access is defined from the length of field and the INCREMENT definition of the range for the access as defined by ASSIGN fld+n*sizeof[field] (sizeof[fld]) TO <fs>. The addressed range must lie within the range limits. If it is not possible to make the assignment because the range limits were violated, SY-SUBRC is set to > 0 and the field symbol is not changed.
The range limits for ASSIGN field INCREMENT n TO <fs> are defined in exactly the same way as ASSIGN field TO <fs>. The definition of the INCREMENT therefore has no effect on the definition of the range limits.
You use the DEFAULT addition as follows to address the individual components of the first row:
To fill only the LOW field (single field comparison), use:
........DEFAULT <g>.
To fill the LOW and HIGH fields (range selection), use:
........DEFAULT <g> TO <h>.
To fill the OPTION field, use:
........DEFAULT <g> [to <h>] OPTION <op>.
For single field comparisons, <op> can be EQ, NE, GE, GT, LE, LT, CP, or NP. The default value is EQ. For range selections, <op> can be BT or NB. The default value is BT.
To fill the SIGN field, use:
........DEFAULT <g> [to <h>] [OPTION <op>] SIGN <s>.
The value of <s> can be I or E. The default value is I.
The input fields of the selection criterion are filled with the default values. The user can accept or change these values.
REPORT DEMO.
DATA WA_SPFLI TYPE SPFLI.
SELECT-OPTIONS AIRLINE FOR WA_SPFLI-CARRID
DEFAULT 'AA'
TO 'LH'
OPTION NB
SIGN I.
Kevin
‎2008 Mar 05 3:33 PM
Hi,
Please refer to the docu below, direct extract from ABAPDOCU
RANGES
Basic form
RANGES sel FOR f.
Addition:
... OCCURS n
This statement is not allowed in an ABAP Objects context. See Prohibit RANGES.
Effect
Defines an internal table similar to a selection
criterion sel defined using the SELECT-OPTIONS sel FOR f statement.
The above statement is identical to:
DATA: BEGIN OF sel OCCURS 10,
SIGN(1),
OPTION(2),
LOW LIKE f,
HIGH LIKE f,
END OF sel.
Note
If you use the IN operator in conjunction with SUBMIT, CHECK, IF, WHILE or SELECT, always define the associated internal table using SELECT-OPTIONS or RANGES (never directly).
Addition
... OCCURS n
Effect
Changes the OCCURS value 10 to the value of occ.
Thanks,
Sriram Ponna.
‎2008 Mar 05 3:37 PM
Hi,
Ranges will just act as select options.
So if u want to compare some range of values(Known) in the select statement then instead of having one dummy select-option we can have range.
SELECT ....
FROM...
INTO TABLE...
WHERE field1 IN r_range1.
Thanks,
Vinod.
‎2008 Mar 06 6:12 AM
Hi
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
Thanks&Regards,
Chaithanya.