cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Error

Former Member
0 Kudos

Dear All,

Am getting wired error in Advanced UDF.

PI getting the Input as String[] a={"01","02","03","04","05","06"}; .and its returning the output as 1 instead of 6 when i am trying to get the length of the String Array

find below sample code:

Assume that array string " b "has a value {"a","b","c","d","e","f"}

public void Sample(String[] a,String[] b,String[] c,String[] d,ResultList result,Container container)

{

HashMap y=new HashMap();

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

y.put(""b of [ i ],""a of [ i ]);

} note : i used b of i instead actual because here its doesn't allow me to use exact one what we use in coding

i am trying to read all the value of the string array "a" to HashMap " y" for some other calculation but PI copy only the first value i.e "01"

Thanks in advance for your valuable solutions

Regards,

Manikandan

Accepted Solutions (0)

Answers (2)

Answers (2)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>y.put(""b of i ,""a of i );

Change into below and test

y.put(b<i>, a<i>);

Former Member
0 Kudos

HI baskar,

i was trying like above but when i try to type here it was not showing properly that's why i have given the note next to the code

but now i got to know how to post the code.

y.put(b<i>, a<i>);

.

public void Sample(String[] a,String[] b,String[] c,String[] d,ResultList result,Container container)
{
HashMap y=new HashMap();

for(int i=0;i<a.lenght;i++)
y.put(""+b<i>i ,""+a<i> );

} 

former_member184681
Active Contributor
0 Kudos

Hi,

Try with the code here:

http://ideone.com/sVDcf

Compiled successfully and seems to work well you can add System.out.println(y); at the end to verify.

Hope this helps,

Greg

iaki_vila
Active Contributor
0 Kudos

Have you tried to pass to UDF all the context?

If the queue only returns one value it could be that the UDF only returns a single value or only one context value.

Regards.

Former Member
0 Kudos

Hi Iñaki Vila ,

I am passing all the context value to the UDF and the same code is executes perfectly in Eclipse and the same JRE version is used and PI version is 7.0

I required all the context value to perform the calculation but PI reads only first value of the context and getting Null pointer exception when code trying to use the second value.

I am pretty sure that we are using cache as a context and not a value so PI gets the whole context as a input

Regards,

Manikandan