‎2006 Sep 04 1:26 PM
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.
‎2006 Sep 04 1:28 PM
Try using the RANGES..
IF your value is in the range
YOUR CODE
ENDIF
thnx
‎2006 Sep 04 2:44 PM
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
‎2006 Sep 04 1:45 PM
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
‎2006 Sep 04 1:51 PM
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.