on 03-12-2009 12:21 PM
HI,
I have a scenario as below.
I get four values from the input and are compared to a constant value each . Based on this the value needs to be passed to the result. I know this is possible using mapping functions but some how it is giving me some error.Now I want to use a UDF for this.I have written the below UDF but it does not work and gives me error
if ((i==1) || (j==B)) && ((i==2) || (j==D)) {
result.addValue( ' X ' );
}
else {
result.Value( 'Y");
}
Can anyone please provide the correct inputs afor this one.
Error is incompatible types found : char and operator && cannot be applied to java.lang.String[],java.lang.String[]
Hi Amit,
You can use this mapping:
constant: X \
\
i --> equalsS------> or -----> and --> ifThenElse --> target
constant:1 / / / /
/ /constant:Y /
j --> equalsS ----> / /
constant:B / /
/
i --> equalsS------> or --> /
constant:2 / /
/
j --> equalsS ----> /
constant:D /
Hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Note all input that comes into the UDF is treated as a string in version < PI 7.1
so you code is
if ((i==1) || (j==B)) && ((i==2) || (j==D)) {
result.addValue( ' X ' );
}
else {
result.Value( 'Y");
}
Now assuming that i and j are your input fields;
if its a simple UDF then;
your code sud be
if ((i.equals("1") || (j.equals("B")) && ((i.equals("2") || (j.equals"D")) {
return("X");
}
else {
return("Y");
}
if an advanced UDF then, you will have to introduce a for loop through loop through all the context values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit
try this
if ((i==1) || (j.equals(B))) && ((i==2) || (j.equals(D))) {
result.addValue( ' X ' );
}
else {
result.Value( 'Y");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> else {
> result.Value( 'Y");
> }
You have to use
result.addValue( "Y");
in double quotes.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
i and j are integers as per my understanding. if it is so then i think B and D are the inputs. Check if the input type is string or int.
If it is string the please collect this value into an integer variable.
like int k = Integer.parseInt(B) ; check the conditions with K.
Let us know if you still have the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Give if Condition like
if ((i=='1') || (j=='B')) && ((i=='2') || (j=='D')) {
result.addValue( ' X ' );
}
else {
result.Value( 'Y");
}
and try..
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
Check the Parenthesis in the IF condition.
Thanks,
SaNv...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.