cancel
Showing results for 
Search instead for 
Did you mean: 

UDF error

Former Member
0 Kudos

Hi,

I want UDF for getting all the values in a context in a single string each value separated by semi-colen.Iam using the following UDF for that :

public void seperator(String[] a[[]],ResultList result,Container container){

//write your code here

String target="";

for(int i = 0;i<a.length;i++)

target = target+a<i>;

if ( ! i == a.length-1)

{

// if i not equal to a.length -1

target = target+";";

}

result.addValue(target);

}

But it is throwing the syntax error

Source code has syntax error: /usr/sap/YXD/DVEBMGS52/j2ee/cluster/server0/./temp/classpath_resolver/Mapffe57490524d11dd9c650014c2650023/source/com/sap/xi/tf/_Mapping name_.java:610: ']' expected public void seperator$(String[] a[[]],ResultList result,Container container){ ^ /usr/sap/YXD/DVEBMGS52/j2ee/cluster/server0/./temp/classpath_resolver/Mapffe57490524d11dd9c650014c2650023/source/com/sap/xi/tf/Mapping namejava:627: ')' expected } ^

Plz help me on this.Its urgent

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I have done sme thing in my project. here is the UDF.

public void ConcatAllOptions(String[] option,ResultList result,Container container){

String output = "" ;

for( int i = 0; i< option.length; i++ )

{

output = output + option<i>;

if ( i != option.length - 1 )

{

output = output + "," ;

}

}

result.addValue(output);

let me know if you face any difficulty.

Regards,

Sarvesh

Answers (12)

Answers (12)

Former Member
0 Kudos

Yes..Its working fine now.........changed output = output + option as output = output + option[<i>]

Thanks All

Edited by: nagarjuna _s on Jul 16, 2008 10:56 AM

Edited by: nagarjuna _s on Jul 16, 2008 10:56 AM

Edited by: nagarjuna _s on Jul 16, 2008 10:58 AM

Edited by: nagarjuna _s on Jul 16, 2008 10:58 AM

Edited by: nagarjuna _s on Jul 16, 2008 10:59 AM

Edited by: nagarjuna _s on Jul 16, 2008 11:01 AM

Former Member
0 Kudos

I want the multiple values(email address) in the context should should come as one string with seperator as semi-colen.

The UDF provided by sarvesh has been doing this.But the problem is...instead of getting those values that i have passed it is showing like this-

[Ljava.lang.string;@6a1b33cb; [Ljava.lang.string;@6f2f27d1;

Please help on this.

Former Member
0 Kudos

Hi,

This is working fine..

public void concat(String[] a,ResultList result,Container container)

{

String output = "" ;

for( int i = 0; i< a.length; i++ )

{

output = output + a<i>;

if (!( i ==a.length - 1 ))

{

output = output+";";

}

}

result.addValue(output);

pls modify stmt as specified by gabriel

but change the context of source node to higher level..

Edited by: malini balasubramaniam on Jul 16, 2008 8:20 AM

Former Member
0 Kudos

Hi,

Check this..it's working fine..

While creating UDF use the option value

public String check(String a,Container container)

{

//write your code here

String target = "";

int i;

for( i = 0; i<a.length(); i++)

{

target = target + a;

if (!(i == (a.length()-1)))

{

target = target + ';' ;

}

}

return target;

}

Former Member
0 Kudos

No...it is showing the same thing without that special char.Is there any thing to modify in UDF...?

Former Member
0 Kudos

No need to modify the UDF if you have created the same way as I suggested you. It is very strange the smae solution for me working fine even in production system.

Former Member
0 Kudos

Hi,

Use the below code (given by Sarvesh) and just change the context of the Source element to higher level.

I tested it and it is working fine.

public void ConcatAllOptions(String[] option,ResultList result,Container container){

String output = "" ;

for( int i = 0; i< option.length; i++ )

{

output = output + option<i>;

if ( i != option.length - 1 )

{

output = output+";";

}

}

result.addValue(output);

Former Member
0 Kudos

The field get multiple email values and should seperate them by ; .The email string is not getting properly...u can see Ljava.lang over there beside @

Former Member
0 Kudos

I think it is a problem of special char "@". Just for testing purpose pass some other data to this UDF and then try.

Former Member
0 Kudos

I set context button only

Former Member
0 Kudos

In what situation (what kind of data) you get this kind of string??

What test data you are passing to your mapping.

Also check the context of source message.

Former Member
0 Kudos

The UDF is working fine now.but in the target the corresponding field is showing like

[[Ljava.lang.string;@161b7116 ;[ljava.lang.string;@161b7116

Former Member
0 Kudos

your UDF is set to what, I mean Value or Context or Queue??

use the Context radio button and then try.

Former Member
0 Kudos

Thanks All....the problem got solved.

Former Member
0 Kudos

Hi what I can see is this

public void seperator(String[] a[[]],ResultList result,Container container){

Remove this(.String[] a[[]],)

U need to specify this in your Context option of UDF

It will look like this.

The above line should look like this in udf

-


public void Tesst(String[] a,ResultList result,Container container){

-


String target="";

for(int i = 0;i<a.length;i++){

target = target+a;}

if ( ! i == a.length-1)

{

target = target+";";

}

result.addValue(target);

-


}

-


Regards

Abhishek Mahajan

**PLease reward points if helpful**

Former Member
0 Kudos

Hi ,

Pls make changes to ur code to remove the syntax errors -

public void seperator(String[] a[[]],ResultList result,Container container)

Change the variable declartion in UDF. Just give a as argument then it changes the function like this -

public void seperator(String[] a,ResultList result,Container container

target = target+";";

Change this like this if you want to add ';' in the target string -

target = target+ ';' ;

Regards,

Kishore

GabrielSagaya
Active Contributor
0 Kudos

please modify the statement as target = target+a[<i>]

public void Tesst(String[[]] a,ResultList result,Container container){

String target="";

for(int i = 0;i<a.length;i++)

target = target+a[<i>];

if ( ! i == a.length-1)

target = target+";";

result.addValue(target);

}

aashish_sinha
Active Contributor
0 Kudos

Hi,

Please remove additional brackets here or remove brackets after a[[]]

>>>>public void seperator(String[] a[[]],ResultList result,Container container

use it like

public void seperator(String[] a,ResultList result,Container container

Hope this will help you

Regards

Aashish Sinha

PS : reward points if helpful