cancel
Showing results for 
Search instead for 
Did you mean: 

UDF: Java error code.

Former Member
0 Kudos

Hi ,

I have written a basic Java UDF to calculate the length of the incoming string without counting the whitespace(blanks) in this string.

In the code below I am trying to add the character count of string to a global container gw_len.

//write your code here
int i = a.length();
String b="";
Char c;
for (int j=0; j<i; j++)
{
c=a.charAt(j);
if (c!=' ')
 gw_len = gw_len + 1;
}
return a;

However upon activation I get the following error:

Source code has syntax error:  D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map6b95a7e063c511ddb480001a4b52813a/source/com/sap/xi/tf/_MM_ALLOCATION_RESPONSE_.java:384: incompatible types found : char required: java.lang.String c=a.charAt(j); ^ 

D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map6b95a7e063c511ddb480001a4b52813a/source/com/sap/xi/tf/_MM_ALLOCATION_RESPONSE_.java:385: operator != cannot be applied to java.lang.String,char if (c!=' ') ^ 

2 errors

Can you Java experts help let me know where my code is wrong.

Thanks

Shirin

Accepted Solutions (1)

Accepted Solutions (1)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

You can even do this using the standard graphical mapping function.

Use this mapping pattern http://www.flickr.com/photos/28929439@N06/2740038189/

Thanks

SaNv...

Former Member
0 Kudos

You are an expert in Java and XI.

Many thanks for the help.

Regards

Shirin

Answers (1)

Answers (1)

Former Member
0 Kudos

Solved.

Changed 'Char' to 'char' and problem solved.

Regards

Shirin