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

Setting IF condition for random values

Former Member
0 Likes
587

Hi,

for IF statement i want to check one variable value with a set of random values say e.g ( 10, 23, 234, 3, 45, ...)

What is the optimized way to do that?

Plz LMK your comments.

Thanks in advance.

4 REPLIES 4
Read only

Former Member
0 Likes
552

Try using the RANGES..

IF your value is in the range

YOUR CODE

ENDIF

thnx

Read only

0 Likes
552

Thanks a lot friends,

I already used RANGES but as I have many Values to compare I am not preferring Ranges.

Do tell if any other solution.

Thanks

Read only

Former Member
0 Likes
552

Hi,

As Sachin wrote , you can use declare a Range type and

populate it with all the possible values. Then check if you variable lies in that range.

e.g.

Sample code:

Data: w_val type i.

Ranges: r_val for <field type>.

clear: r_val, r_val[].

r_val-option = 'I'.

r_val-sign = 'I'.

r_val-low = 10.

append r_val.

r_val-low = 23.

append r_val.

r_val-low = 234.

append r_val.

If w_val not in r_val.

message 'Incorrect value' type 'E'..

endif.

If you want to do some processing at diffent values, u can use a Case statement.

Case w_val.

when '10'.

...

when '23'.

when other..

Encase.

Regards

Read only

Former Member
0 Likes
552

Hi shital,

Should you generate the random number also? or do you need to check the value obtained already....

you can use RANDOM_I4 or RANDOM_I2 for getting 4 digit/2digit numbers....(give the range between which you want to get the random values)....

you can take these values into a range and check if your required value is in the range.......

Regards,

Vidya.