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

IN range comparison

Former Member
0 Likes
1,171

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

10 REPLIES 10
Read only

DirkAltmann
Active Participant
0 Likes
1,131

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

Read only

Former Member
0 Likes
1,131

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.

Read only

Former Member
0 Likes
1,131

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

Read only

former_member404244
Active Contributor
0 Likes
1,131

Hi,

U have to use append statement..

sign = 'I',

option = 'BT'.

low = '200'

high = '400'

append lr_check_value . it will work..

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,131

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.

Read only

Former Member
0 Likes
1,131

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

Read only

Former Member
0 Likes
1,131

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!

Read only

0 Likes
1,131

Yeah ,

check with low value as 085 , it worked

r_auwrt-low = '085'.

Read only

0 Likes
1,131

Ohh great..you solved it...

Read only

Former Member
0 Likes
1,131

TS,

can you debug the program and check the values in the range lr_check_value.