cancel
Showing results for 
Search instead for 
Did you mean: 

Help required in writing UDF

Former Member
0 Kudos

Hi SDNers,

I have a requirement to write UDF, can anybody help me in acheiving the code.

Requirement:-

If I am getting 5 as my input to UDF, I need to generate five 001's to my output of UDF.

I tried to loop the input and used result.addValue("001"); but not working.

Please help in getting java logic for this udf.

Thanks

Jayaram.G

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

chk this:

Exceution type: all values of a context

Input will be "a"


int bb =Integer.parseInt(a[0]);

for(int i=0;i<bb;i++)
{
result.addValue("001");
}

Note: tweak this code to achieve ur functionality

Answers (3)

Answers (3)

former_member184681
Active Contributor
0 Kudos

Hi,

Make sure that you have set the ResultList as the Java Type of your return parameter. Otherwise, you will not be able to output multiple values. Moreover, you might want to have a look at standard function useOneAsMany, as you might be able to achieve your goal using it.

Hope you'll find this useful,

Greg

Former Member
0 Kudos

Hi,

so, you need five (001's) for 5 input &

ten(001's) for 10 input.

is this dynamic. can the input be any number??

& do u want output as (001001001001001) for 5 input.

Or do u need it in array output.

pls give a example.

-santosh.

Former Member
0 Kudos

Hi

I tried to loop the input and used result.addValue("001"); but not working.

Do you use choose function by context or by queue?

Regards.

Former Member
0 Kudos

Hi Luis,

Thanks for your quick response.

I am using context in my udf.

My code is like this.

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

{

result.addValue("001");

}

As I am getting 5 as input and I am using Var1.length, the udf is generating only one 001. But I need five 001.

Regards,

Jayaram.G