cancel
Showing results for 
Search instead for 
Did you mean: 

UDF code issue

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

a) sorry, I made a mistake. No brackets in return statement.

b) I have no idea why your code does not work, it seems correct.

Edited by: Stefan Grube on Mar 31, 2010 9:26 AM

Former Member
0 Kudos

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

Answers (2)

Answers (2)

rajasekhar_reddy14
Active Contributor
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

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