on 10-27-2021 2:54 PM
Hi,
My rule is checking that MSTA-material status is not equal to 18-55. The range function didn't work since the datatype is varchar so I it like this but when I test the rule then it's not working and values that are supposed to fail are not doing so... Hence I get a full score on rule result which is not correct.
How can I make this rule work?
Hi Ushna,
the code block will always return TRUE, because you are checking if the "number in the string" is either
{ NOT 18
or
NOT 55
or
NOT 50}
whatever number you put in, none of the checks is returning TRUE and with that the whole expression is TRUE.
Why not convert the input field (char) into a number (with a conversion function/expression) and then in the rule code check if the Numebr is smaler than 18 or larger than 55?
Niels
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the reply!
But how can I convert varchar to integer? I didn't find any function for that...
I have previously just changed the data type from varchar to int (both in the view and in the rule) and used a rule for if the Number is smaller than 18 or larger than 55 but that didn't work either...
And we have previously made rules like this which worked fine so don't know why it's not working when I choose "not equal to"...
Hi Ushna,
Information Steward is trying to do implicit type cast if "necessary/possible". String to a Integer is one (see Manual: Conversion among number data types - SAP Help Portal).
Keep the Rule Parameter as varchar (if you bind to a varchar column) and cast at the beginning of your Expression.
DECLARE
$loc_MSTAE int;
BEGIN
$loc_MSTAE =$MSTAE;
IF ($loc_MSTAE > 18 AND $loc_MSTAE < 55)
RETURN TRUE;
ELSE
RETURN FALSE;
END
With regards to your first rule expression. If you combine the 3 "is not" checks with an OR, the logical result is that ANY number is fulfilling "at least ONE" of the OR conditions and with that the result is always TRUE and EVERY number will be passing your rule.
Niels
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.