Application Development and Automation 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: 
Read only

Ranges

Former Member
0 Likes
933

Hi

Can any tell the use of ranges and also the procedure to create ranges. If possible with the code.

Thanks in advance

Haritha

9 REPLIES 9
Read only

anversha_s
Active Contributor
0 Likes
900

hi,

Define a range: same like select-options.

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.

rgds

anver

if hlped rwd points

Read only

Former Member
0 Likes
900

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.

<b>Definition</b>

RANGES : r_werks FOR mard-werks,

r_lgort FOR mard-lgort.

<b>Filling it with data</b>

r_werks-sign = 'I'.

r_werks-option = 'EQ'.

r_werks-low = p_werks1.

APPEND r_werks.

CLEAR r_werks.

<b>Usage</b>

SELECT * from marc where werks in r_werks.

Message was edited by: Anurag Bankley

Message was edited by: Anurag Bankley

Read only

Former Member
0 Likes
900
ranges are similar to select options

ranges: sel FOR f. 

this is same as

DATA: BEGIN OF sel OCCURS 10, 
         SIGN(1), 
         OPTION(2), 
         LOW  LIKE f, 
         HIGH LIKE f, 
      END   OF sel.

Message was edited by: Chandrasekhar Jagarlamudi

Read only

0 Likes
900

Hi,

A little bit more info.

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.

Regards,

Johnson

Read only

0 Likes
900

Additionally..

DATA itab TYPE RANGE OF type.

DATA itab LIKE RANGE OF f.

creates an internal table that can be used as a range

SIGN(1) TYPE C

OPTION(2) TYPE C

LOW TYPE type bzw. LIKE f

HIGH TYPE type bzw. LIKE f

Read only

Former Member
0 Likes
900

Hi guys

Thanks for quick response.

I have a requirement to get current accounting date and comparision date by performing some logic, and to put both these dates in ranges. So does it mean that i have to create a table then put both these dates in that table and create a range in the program or what.

Thanks

Haritha

Read only

0 Likes
900

lcurracdate <= current accounting date.

lcalcompdate <= calculated comparision date.

*Lets say your lcalcompdate is always going to be greater than lcurrdate.

range : r_date for sy-datum.

r_date-low = lcurracdate.

r_date-high = lcalcompdate.

r_date-sign = 'I'.

r_date-option = 'BT'.

append r_date.

and in your logic you can use the above range to select data which fall within the defined range.

Regards

anurag

Please assign points for helpful answers !

Read only

Former Member
0 Likes
900

Hi,

ranges are similar to select-options but

can't be displayed on screen.

ranges has limitation i.e it can't hold more data

where as selectoptions can hold large data.

example of ranges

ranges:r_matnr for mara-matnr.

r_matnr-sign = 'I'.

r_matnr-option = 'EQ'.

r_matnr-low = '100'.

r_matnr-high = '200'.

append r_matnr.

Regrads

Amole

Read only

Former Member
0 Likes
900

Hi,

the best way is to create in TA se11 a 'Ranges' table type. Call TA se11, push the radio button 'table type' and choose 'edit' and finally 'define as ranges table type' (or something like that). Then use this newly created data type in your program. It also can be used in select statements.

Regards,

Thomas