cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting the values

Former Member
0 Kudos

Hi I am Passing this value as input

<input>GROUP1,CODE1,DESC1;GROUP2,CODE2,DESC2;GROUP3,CODE3,DESC3</input>

I need to get output as

<A>

<ABC>

<el1>GROUP1</el1>

<el2>CODE1</el2>

<el3>DESC1</el3>

</ABC>

<ABC>

<el1>GROUP2</el1>

<el2>CODE2</el2>

<el3>DESC2</el3>

</ABC>

<ABC>

<el1>GROUP3</el1>

<el2>CODE3</el2>

<el3>DESC3</el3>

</ABC>

</A>

Please guid me how to proceed

Regards

Krishna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Krishna,

You have to use UDF for this requirement.

Check the below thread, similar issue is discussed in it:

-Supriya.

Former Member
0 Kudos

Hi Supriya,

Thanks for Your reply,

this link will not help me , with this code I can able to genarate multiple occrances but I am unable to pass the exact values.

Please guid me how to pass exact values using UDF?

Former Member
0 Kudos

Any Solution Regarding this?

former_member191531
Participant
0 Kudos

Hi Krishna,

I've a solution, which expects exact one input string.

For the node ABC use the following UDF (ExecutionType: All Values of a Context; 1 argument):

String[] values = var1[0].split(";");
for (int i = 0; i < values.length; i++) {
    result.addValue("");
}

For the other nodes (el1, el2, el3) use the following UDF (ExecutionType: All Values of a Context; 2 arguments):

String[] values1 = var1[0].split(";");
int pos = Integer.parseInt(var2[0]);
for (int i = 0; i < values1.length; i++) {
    String[] values2 = values1<i>.split(",");
    result.addValue(values2[pos]);
    result.addContextChange();
}

Use the following constants as second argument:

el1 -> 0

el2 -> 1

el3 -> 2

Regards,

Juergen

Edited by: Juergen Grallert on Sep 8, 2010 1:29 PM

Former Member
0 Kudos

Use this UDF to solve your problem..

Create UDF with context as Queue and declare the input variable as 'a'.

String[] outstr1  = a[0].split(";");
 
 for (int i = 0; i < outstr1.length; i++)
{   
String[] outstr2  = outstr1<i>.split(",");

 for (int j = 0; j < outstr2.length; j++)
{   
result.addValue(outstr2[j]);
}
result.addValue(ResultList.CC);
}

Former Member
0 Kudos

Hi juergen,

Your code is working perfectly thanks a lot..

Regards

krishna

Answers (0)