cancel
Showing results for 
Search instead for 
Did you mean: 

UDF required

Former Member
0 Kudos

Hi Experts,

The requirement of mapping ia as fallows.

Based on Field1, the Field2 value populates no.of times of the Field1.

Field1 contains 3 , Field2 Contains "AAA".The required output would be as "AAA","AAA","AAA" in three records.Can anyone give the UDF.

Thanks,

Tiger Woods

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi All,

Thanks a lot for your replies.My problem was solved with function which was given by Venkat.

former_member189558
Contributor
0 Kudos

Hi Tiger,

Use the function "UseOneAsMany" ...

Cheers,

Himadri

Former Member
0 Kudos

Hi,

The required output like below but that is for three records.

<target>AAA</target>

<target>AAA</target>

<target>AAA</target>

If Field1 contains value as 5 , then the ouput of Field2 as above(5 times).

Thanks,

Tiger Woods.

Former Member
0 Kudos

Hi,

I have given the UDF for the same. Give it a try.

Regards,

P.Venkat

Former Member
0 Kudos

Hi Triger,

If you are sepearating your input by using any delimiter like aa,aa,aa then this code will work and it creates the target structure like:

<target>AAA</target>

<target>AAA</target>

<target>AAA</target>

<target>AAA</target>....hw many times you mentioned in your input filed those many times it will get appear in target side.

Note:here a is the argument.

String str=a.split(a[0],",");

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

{

result.addvalue(a<i>)

}

Hope this code will solve your peoblem.

Let me know if you have any queries.

Thanks

Sekhar

Former Member
0 Kudos

Hi,

You can make use of Venkat's code.

Just make sure, that your taget node is of occurance 1..unbounded

and the source nodes always have the value. If there is no value in either of the source fileds it will result in an error.

Regards,

Jai Shankar

Former Member
0 Kudos

Hi,

How would you need the target? Is it some thing like

<target>AAA</target>

<target>AAA</target>

<target>AAA</target>

or

<target>AAAAAAAAA</target>

Regards,

Jai Shankar

Former Member
0 Kudos

Hi,

Is the output 3 nodes containing "AAA", then go for this UDF.

select queue tyep.

Input:field1, field2


int val = Integer.parseInt(field1[0]);
for(int j=0; j< val; j++){
   result.addValue(field2[0]);
}

Regards,

P.Venkat