cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Code required

Former Member
0 Kudos

Hello gurus ,

I need a java code to split a string coming from source side to target 3 elements

For example i am getting a value"INDIA WON MATCH" from source side string value.

I need to split it into three values say

variable one towards the target side needs "INDIA"

Variable 2 need"WON"

Variable 3 needs"MATCH"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

Create a Value user defined function and name it as replace. Take one argument as a.

Import: java.*;

Add this code:

int i = a.indexOf(" ");

a = a.substring(0,i);

return(a);

Then map like this:

source --> replace(udf) --> Target

This will always take the value before -.

Thanks,

Vijaya.

Answers (4)

Answers (4)

GabrielSagaya
Active Contributor
0 Kudos

You should opt Advanced UDF

function myudf(String a, ResultList result, Container container)

{

String [[]] temp = null;

temp = a.split(" ");

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

result.addValues(temp[<i>]);

}

make targe node as o..unbounded.

source msg> myudf>splitbyByValue(each Value)>CollapseContext>Target node

aashish_sinha
Active Contributor
0 Kudos

Hi ,

Write an UDF something like this.

define a result String array in which u will return the values. lets sat its result[] of type String

//write your code here

String res = "";

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

{

if(xmlString.charAt !='')

{

res = res + xmlString.charAt (i);

}

else

{

Add values to your String Array;

reset value of string res; //to take next values

}

}

return result[];

hope this will help you.

Regards

Aashish Sinha

PS : reward points if helpful

Former Member
0 Kudos

Hi,

There is a process in graphical mapping look at the below blog, its done in graphical mapping

/people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool

Thanks

Vikranth

Former Member
0 Kudos

String input = "INDIA WON MATCH"

String [ ] StrArray = input.split(" ");

variable1 = StrArray[0];

variable2 = StrArray[1];

variable3 = StrArray[2];