Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
LaurensDeprost
Contributor


About ranges and select-options


Ranges are internal tables with the same structure as a selection table. They are very useful for flexible reading of database data in ABAP. Ranges tables always consist of four columns:



































Field Description Examples
SIGN whether records should be in- or excluded ‘I’ = Include
‘E’ = Exclude
OPTION the selection operator ‘EQ’ = Equal
‘BT’ = Between
‘GT’ = Greater than
LOW the lower limit of the interval
HIGH the higher limit of the interval











💡 Ranges? Select-options?

Ranges, or ranges tables, are internal tables containing the four columns listed above. They are declared with syntax TYPE RANGE OF.

Select-options, on the other hand, refer to selection criteria on selection screens, which are linked with automatically generated selection tables. These are global internal tables with header line, that share the same layout as ranges tables.

Convert internal tables to ranges


Since ABAP 7.40 the FOR operator allows simple conversion from internal table to ranges table, without the need of directly looping over the table.
DATA(material_range) = 
VALUE rsdsselopt_t(
FOR material IN materials
( sign = if_fsbp_const_range=>sign_include
option = if_fsbp_const_range=>option_equal
low = material-matnr ) ).

To do the opposite and extract data from a ranges table, use CORRESPONDING together with MAPPING.
materials = CORRESPONDING #( material_range MAPPING low = matnr ).

 


 

Fill ranges directly from SELECT statements


Gone are the days when it was necessary to first select data and then loop over it to fill a range. With the current syntax, ranges can be filled directly in the SELECT statement.
SELECT 'I' AS sign, 
'EQ' AS option,
matnr AS low, matnr AS high
INTO TABLE @DATA(material_range)
FROM mara.


 

Ranges allow for flexible openSQL selections

 


What is your experience using ranges tables and select-options in ABAP?
Have you got any helpful tips or tricks to share?
Let us know in the comments! 👇
13 Comments
Labels in this area