2008 Mar 24 11:22 AM
Hi,
What is the use of declaring Ranges,explain?
Thanks.
2008 Mar 24 11:26 AM
Hi,
see this code then u can understand the usage
DATA: spfli_wa TYPE spfli,
r_carrid TYPE RANGE OF spfli-carrid,
r_carrid_line LIKE LINE OF r_carrid.
r_carrid_line-sign = 'I'.
r_carrid_line-option = 'BT'.
r_carrid_line-low = 'AA'.
r_carrid_line-high = 'LH'.
APPEND r_carrid_line TO r_carrid.
SELECT *
FROM spfli
INTO spfli_wa
WHERE carrid IN r_carrid.
...
ENDSELECT.
rgds,
bharat.
2008 Mar 24 11:27 AM
2008 Mar 24 11:28 AM
RANGES
Declares a RANGES table.
Syntax
RANGES <rangetab> FOR <f>.
Declares a RANGES table for the field <f>. A RANGES table has the same data type as a selection table, but is not linked to input fields on a selection screen.
2008 Mar 24 11:29 AM
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.
2008 Mar 24 11:29 AM
Hi,
Please refer documentation below :
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 24 11:33 AM
Ranges provide a number of coding benefits.
During a SELECT
SELECT * INTO TABLE IT_TEMP
FROM mara
WHERE MATNR IN R_MATNR.
Also in an IF.
IF temp_rec-matnr IN R_MATNR.
.. Do Something
ENDIF.
This also can be used in LOOP or basically anywhere that a CONDITION can be coded.
In report programs, the LOAD-OF-PROGRAM or INITIALIZATION sections can build ranges for the selection screen to limit or prefill information on it.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |