on 03-31-2010 7:45 AM
Hi
I am getting errors in this java code
kindly help
public String CheckCode(String inputCode,Container container)
{
if(inputCode.equals("AED")||inputCode.equals("AFA")|| inputCode.equals("AFN")||................inputCode.equals("FGH"))
return true;
else
return false;
}
I am using this in graphical mapping , as a condition to create the target structure if the value of the input node is AED , AFA or AFN
inputfield --> CheckCode -
>if
Constant(true)--->then---> Target
Can anyone please tell me what is wrong ??
the error that i am getting while activating mapping is
1) incompatible types found : boolean required: java.lang.String return true;
2) incompatible types found : boolean required: java.lang.String return false;
3)cannot resolve symbol
symbol : variable inputCode
location: class com.sap.xi.tf._MM_ABC_ inputCode.equals("AFA")||
I have two questions :
1) Are the parantheses or the brackets in the if condition fine ?
2) is there a problem with the || symbol
3) what is the boolean required for ???
thanks
Dev
Hi sd,
By default the return type of any UDF is either a string or void.
Thtz the reason u r getting
1) incompatible types found : boolean required: java.lang.String return true;
2) incompatible types found : boolean required: java.lang.String return false;
and for
3)cannot resolve symbol
please check u r using inputCode consistently.
1) Are the parantheses or the brackets in the if condition fine ?
No thtz fine
2) is there a problem with the || symbol
NO thtz fine
3) what is the boolean required for ???
not required.
U please alter code like,,,,
public String CheckCode(String inputCode,Container container)
{
String returnValue = "false";
if(inputCode.equals("AED")||inputCode.equals("AFA")|| inputCode.equals("AFN")||................inputCode.equals("FGH"))
returnValue = "true";
else
//nothing
return returnValue;
}
true----
inputfield --> CheckCode -
equlasS(Text function)>if
Constant(true)--->then---> Target
pass a constant true to equlasS.
This will also work.
Babu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi babu
I have two questions :
a) if i use the method as told by Stefan and Reddy do i have to use it like this ?
if(inputCode.equals("AED")||inputCode.equals("AFA")||inputCode.equals("AFN"))
return "true";
else
return 'false";
or
return ("true");
else
return ("false");
b) why am i getting this error
cannot resolve symbol
symbol : variable inputCode
location: class com.sap.xi.tf._MM_ABC_ inputCode.equals("AFA")||
Is it because i may be using some other input Name as input variable, some where ??
Dev
Hi sd,
a) if i use the method as told by Stefan and Reddy do i have to use it like this ?
if(inputCode.equals("AED")||inputCode.equals("AFA")||inputCode.equals("AFN"))
return "true";
else
return 'false";
or
return ("true");
else
return ("false");
Not both
use
if(inputCode.equals("AED")||inputCode.equals("AFA")||inputCode.equals("AFN"))
return "true";
else
return "false"; // check u have given single quotes.
b) why am i getting this error
cannot resolve symbol
symbol : variable inputCode
location: class com.sap.xi.tf._MM_ABC_ inputCode.equals("AFA")||
Is it because i may be using some other input Name as input variable, some where ??
exactly..
U copy the code to notepad and use find and replace or check clearly once more the names.
it should also be same thing in th input parametrs of UDF also.(pl chk it)
Let us know the result
Babu
Hi,
If you return true ,false without quotes "" it takes as boolean types,so as stefan alredy mentoed declare with quotes,so that it will retunr as string,becase the method you defined is expecting string as a retun type.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
instead of the UDF, use the standardfunction "FixValues".
Assign true to all values and false as default.
inside the UDF you write
return "true"
and
return "false"
you have to return a string, not a boolean.
Edited by: Stefan Grube on Mar 31, 2010 9:24 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.