‎2008 Feb 22 9:40 AM
Hi,
How do I check if a value is in a range?
I am testing the 'IN' clause as follows:-
my test_value is declared as :-
lv_current_value TYPE atwrt, with a value of '210'
my range_table is declared as :-
RANGES: lr_check_value FOR ausp-atwrt.
and has the table entry =
sign = 'I',
option = 'BT'.
low = '200'
high = '400'
I would have expected the following test to come out positive
IF test_value IN lr_check_value.
test = positive
else.
test = negative.
endif.
Can ayone shed any light?
Thanks alot
‎2008 Feb 22 9:49 AM
Hi TS,
the following code works. Compare it with your code:
data test type string.
parameters : lv_value TYPE atwrt default '210'.
RANGES: lr_check_value FOR ausp-atwrt.
lr_check_value-sign = 'I'.
lr_check_value-option = 'BT'.
lr_check_value-low = '200'.
lr_check_value-high = '400'.
append lr_check_value.
IF lv_value IN lr_check_value.
test = 'positive'.
else.
test = 'negative'.
endif.
write test.
Regards
Dirk
‎2008 Feb 22 9:49 AM
Hi,
lr_check_value -sign = 'I'.
lr_check_value -option = 'BT'.
lr_check_value -low = '200'.
lr_check_value -high = '400'.
append lr_check_value.
now you can you 'IN' operator to check.
‎2008 Feb 22 9:51 AM
Hi,
Tried the same code as below:
DATA: p_auwrt TYPE ausp-atwrt VALUE '210'.
RANGES: r_auwrt FOR ausp-atwrt.
r_auwrt-sign = 'I'. r_auwrt-option = 'BT'.
r_auwrt-low = '200'. r_auwrt-high = '400'.
APPEND r_auwrt.
IF p_auwrt IN r_auwrt.
WRITE:/ 'positive'.
ELSE.
WRITE:/ 'negative'.
ENDIF.
and it works perfectly fine.
Just compare your code against this.
Cheers,
Aditya
‎2008 Feb 22 9:53 AM
Hi,
U have to use append statement..
sign = 'I',
option = 'BT'.
low = '200'
high = '400'
append lr_check_value . it will work..
Regards,
Nagaraj
‎2008 Feb 22 9:56 AM
Write the code as :
In your coding UR not giving any default value to test_value .. instead
lv_current_value is defaulted to 210 ..
*my test_value is declared as :-
*lv_current_value TYPE atwrt, with a value of '210'
tables : ausp.
data : test_value TYPE atwrt value '210'.
RANGES: lr_check_value FOR ausp-atwrt.
lr_check_value-sign = 'I'.
lr_check_value-option = 'BT'.
lr_check_value-low = '200'.
lr_check_value-high = '400'.
append lr_check_value.
IF test_value IN lr_check_value.
write 😕 'positive'.
else.
write 😕 'negative'.
endif.
‎2008 Feb 22 9:57 AM
Thanks for the replies...
I was appending to the table but if
you substitute the ranges values to be from value 85 and the to value to be 213
with test value = 200
the test is negative
‎2008 Feb 22 10:00 AM
however if if use '085' to '213' as the range
and test value = 200
the test is +ve
it was the declarationn of the range, which is character based - doh!
‎2008 Feb 22 10:03 AM
Yeah ,
check with low value as 085 , it worked
r_auwrt-low = '085'.
‎2008 Feb 22 10:04 AM
‎2008 Feb 22 10:01 AM
TS,
can you debug the program and check the values in the range lr_check_value.