Create Range Table Type in Data Dictionary

Often, it is sufficient to declare local range table if we want to use it in local classes or programs. However, there’s a need to create global range table when we want to use it for global classes.

Go transaction SE11 to create the structure. Input structure name and click Create.

A popup shown below will appear. Choose Structure and press Enter.

Maintain the components as shown below. For low and high fields, maintain the component type according to your requirements.

Specify the enhancement category.

Press Enter for this information message.

Choose Cannot Be Enhanced. It doesn’t make sense to enhance custom structure anyway.

Activate the structure. Go to SE11 again to create the table type. Input the table type name and click Create.

A popup shown below will appear. Choose Table type and press Enter.

Define as ranges table type.

Maintain Data Element and Structured Row Type created earlier. Activate the table type.

Editor’s Note

Did you know there’s an easier way now to populate values into range table? In the past, we used to select entries into an internal table first. Next, loop the internal table, assign values to structure of the range table, then append to the range table. But, we don’t need to do that anymore. We can select directly into the range table.

Here’s the code snippet.

DATA:
  lt_r_soid TYPE zgb_range_t_soid.

SELECT FROM
  snwd_so
  FIELDS
    'I'   AS sign,
    'EQ'  AS option,
    so_id AS low
  INTO TABLE @lt_r_soid.

Data selected and populated directly into the range table. Convenient, isn’t it?

My wish-list is that we can do ALPHA IN for the low and high values. Please take note to only select minimal records into range table if you want to use it as a where clause for a select statement. Too many entries will lead to short dump to select statement. The number of entries are dependent on server configuration.