‎2006 Sep 14 11:21 AM
Hi
Can any tell the use of ranges and also the procedure to create ranges. If possible with the code.
Thanks in advance
Haritha
‎2006 Sep 14 11:23 AM
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
‎2006 Sep 14 11:23 AM
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
‎2006 Sep 14 11:23 AM
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
‎2006 Sep 14 11:35 AM
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
‎2006 Dec 01 10:12 AM
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
‎2006 Sep 14 11:32 AM
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
‎2006 Sep 14 12:50 PM
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 !
‎2006 Sep 14 12:07 PM
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
‎2006 Oct 23 5:29 PM
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