In SAP, the structure of a single value is sometimes changed to a range structure, which is similar to the SELECTION-OPTION function. SAP provides RANGES to implement this function.
(SELECTION-OPTION is a very powerful function in SAP. It is also often required to be similar to the SELECTION-OPTION function in the program. If no screen is painted, SAP provides the RANGE function)
Example:
DATA: table_t like table of spfli,
Table_wa LIKE spfli.
RANGES: g_ranges FOR spfli-carrid.
* "Single value
* CLEAR G_ranges [].
* G_ranges-sign = 'I '.
* G_ranges-option = 'EQ '.
* G_ranges-low = 'a '.
* APPEND G_ranges.
"Interval
CLEAR g_ranges [].
G_ranges-sign = 'I '.
G_ranges-option = 'BT '.
G_ranges-low = 'a '.
G_ranges-high = 'hh '.
APPEND g_ranges.
SELECT * FROM spfli into table table_t WHERE carrid IN g_ranges.
Loop at table_t INTO table_wa.
WRITE:/table_wa-carrid, table_wa-connid, table_wa-cityto.
ENDLOOP.
G_ranges is equivalent to the type defined by SELECTION-OPTION.
* Options:
* 1. SIGN The values are I and E.I is include,E is exclusion,I is generally used.
* 2. OPTIONIf HIGHIt is null and is selected as a single value.YesLogical operations such as EQ, NE, GT, LE, and LTFor *'sCP inclusionNP is excluded
* If HIGHNot emptySelect rangeAvailable for BT and NB
* 3.LOW Low value
* 4. HIGH High value
Sap abap programming Ranges usage