Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ranges table

Former Member
0 Kudos
4,684

how to create a ranges table

1 ACCEPTED SOLUTION

Former Member
0 Kudos
308

Hi,

First Ranges are similar to select-options.

You declare ranges using the ranges keyword.

For ex:

Ranges r_matnr for mara-matnr occurs 0.

Don't forget to declare mara with the TABLES statement. This creates the ranges internal table with a header. Remember that ranges are similar to select-options. So, the ranges internal table has the same structure as select-options. The structure is as follows...

sign option low high

Hope this answers your question.

Regards,

Koushik

5 REPLIES 5

former_member225631
Active Contributor
0 Kudos
308

If you declare ranges like select-options, ranges table will be automatically created by system.

Former Member
0 Kudos
309

Hi,

First Ranges are similar to select-options.

You declare ranges using the ranges keyword.

For ex:

Ranges r_matnr for mara-matnr occurs 0.

Don't forget to declare mara with the TABLES statement. This creates the ranges internal table with a header. Remember that ranges are similar to select-options. So, the ranges internal table has the same structure as select-options. The structure is as follows...

sign option low high

Hope this answers your question.

Regards,

Koushik

0 Kudos
308

This is a Sample for Creation range Table..............

  • Range Table Declaration

DATA : r_ettyp TYPE RANGE OF vbep-ettyp WITH HEADER LINE.

  • Making The Range Table

r_ettyp-sign = 'I'.

r_ettyp-option = 'EQ'.

r_ettyp-low = 'CP'.

r_ettyp-high = 0.

APPEND r_ettyp.

CLEAR r_ettyp.

r_ettyp-sign = 'I'.

r_ettyp-option = 'EQ'.

r_ettyp-low = 'EP'.

r_ettyp-high = 0.

APPEND r_ettyp.

CLEAR r_ettyp.

Have a nice day..

Former Member
0 Kudos
308
Ranges : R_matnr for mara-matnr.


R_matnr-sign = 'I'.
R_matnr-option = 'BT'.
R_matnr-low = '1000000'.
R_matnr-high = ''.
append R_matnr.
clear R_matnr.

Former Member
0 Kudos
308

Hi,

Check this code.

- Here the range table is for field "company code".

- After that the range table is filled using macro. Using macro you can omit using same code again and again.

-Then this range table is used in select statement.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*--- MACRO - Fill Company Code
DEFINE fill_bukrs.
  r_bukrs-sign     = 'I'.
  r_bukrs-low      =  &1.
  r_bukrs-option  = 'EQ'.
  append r_bukrs.
END-OF-DEFINITION.
 
TABLES: t001.
 
DATA: lit_bkpf LIKE STANDARD TABLE OF bkpf.
 
RANGES: r_bukrs FOR t001-bukrs.  "<-- This is how you define range
 
fill_bukrs '0001'.       "<-- range table is filled using MACRO 
fill_bukrs '0100'.       "     which is defined at the top
fill_bukrs '1000'.
fill_bukrs '1001'.
 
* here DBTAB = database table
* & INTAB = internal table
SELECT *
        FROM <DBTAB>
        INTO TABLE <INTAB>
        WHERE bukrs IN r_bukrs.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Let me know if you have any question.

Regards,

RS