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????

Former Member
0 Kudos
113

hi,

Can ne1 plz tell me the concept of Ranges????

how is is different from the Selection Table????

Where is it used exactly????

Thanks,

Mohit.

5 REPLIES 5

Former Member
0 Kudos
62

hi Mohit,

Check this link

http://www.sap-img.com/abap/difference-between-select-options-ranges.htm

also refer

Regards,

Santosh

Former Member
0 Kudos
62

Hi,

declaration:

ranges: r_matnr type mara-matnr.

  • Filling ranges is similar to select-options.

r_matnr-low = 'I'.

r_matnr-sign = 'EQ'.

r_matnr-low = '000000000000018'.

append r_matnr.

Usage in Selects

select * from mara into table it_mara

where matnr in r_matnr.

Ranges can be described as programatic version of select-option. They are used to filter data from database or internal table. They work similar to select-options.

Definition

RANGES : r_werks FOR mard-werks,

r_lgort FOR mard-lgort.

Filling it with data

r_werks-sign = 'I'.

r_werks-option = 'EQ'.

r_werks-low = p_werks1.

APPEND r_werks.

CLEAR r_werks.

Usage

SELECT * from marc where werks in r_werks

Regards

Former Member
0 Kudos
62

Ranges can be described as programatic version of select-option. They are used to filter data from database or internal table. They work similar to select-options.

Definition

RANGES : r_werks FOR mard-werks,

r_lgort FOR mard-lgort.

Filling it with data

r_werks-sign = 'I'.

r_werks-option = 'EQ'.

r_werks-low = p_werks1.

APPEND r_werks.

CLEAR r_werks.

SELECT * from marc where werks in r_werks.

Former Member
0 Kudos
62

ranges are same like select-options and use is also same ... but the difference is if you declare

select-options : s_matnr for mara-matnr.

it will create the selection screen automatically and user can give the input in thatr field and you can use it further for selecting the data on the user input.

but if you are writting

ranges : s_matnr for mara-matnr.

then selection screen will not be generated and user can not give the input for that .. generally if you want to restrict the select query with some set of values without the user input then use ranges or in some cases for using the index fields also we are passing the empty ranges for increasing the performance.. i.e. if your user want only few fields from the indexed fields in the selection screen then you can use rest of the fields as empty ranges to make use of all the indexed fields to increase the performance.

regards

shiba dutta

Former Member
0 Kudos
62

hi,

<u>Define a range:</u>

Ranges: r_field for <table>.

if not field1 is initial.

r_field-sign = 'I'.

r_field-option = 'EQ'.

r_field-option-low = field1.

append r_field.

endif.

if not field2 is initial.

r_field-sign = 'I'.

r_field-option = 'EQ'.

r_field-option-low = field2.

append r_field.

endif.

if field1 is initial and field2 is initial.

r_field-sign = 'I'.

r_field-option = 'EQ'.

append r_field.

endif.

select * from <table> where field1 in r_field.

The 'I' value in the SIGN field denotes 'Include', that means to Include the values given in the LOW and HIGH fields.

U may use 'E' here to exclude these values, when u r using the range in a SELECT query.

1. select-options is for screen.

2. If we dont want to display anything on screen,

we can use RANGES

having the same functionality

and us it

in sql using IN statement.

Regards

Reshma