cancel
Showing results for 
Search instead for 
Did you mean: 

Need logic for writing UDF

Former Member
0 Kudos

Hi All,

my requirement is below:-

UDF should have 2 inputs.

input 1 has 10 values



abcdf
jasbb
sjkancjn'
jksncj'
dbdchja
jahsbcb
djsbcb
shjscbb
jhcajbb
ahjcbhasbc

2nd input has value like
2
3
3
2


Now my requirement is to  produce outut as below...

abcdf
jasbb
**context change**
sjkancjn'
jksncj'
dbdchja
**context change**
jahsbcb
djsbcb
shjscbb
**context change**
jhcajbb
ahjcbhasbc

Can anyone please help me

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi,

Try this:

inputa = values with abcd etc

input b = numerical values

Create a UDF for queue and give inputa and inputb as inputs to the UDF.

inputa > removecontext->UDF

inputb > removecontext->


int k=0;

for (int i=0;i<inputb.length;i++) {
 for (int j=0;j<Integer.parseInt(inputb<i>);i++) {
   result.addValue(inputa[k]);
   k++;
 }
 result.addContextChange();
}

Regards

Suraj

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

You can also try this :

int countold = 0;

int countnew = 0;

int k = 0;

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

{

countold = countnew + 1;

countnew = countnew + Integer.parseInt(var1<i>);

for( int j = countold-1 ;j<countnew;j++)

{

result.addValue(var2[k]);

k++;

}

result.addContextChange();

}

Regards,

Ganesh

Former Member
0 Kudos

Hi Suraj... many thaks...

ur Code worked @ the fast run......

Edited by: sam kumar on Nov 21, 2009 7:02 PM