cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Help Please

Former Member
0 Kudos

Hi Guys,

I am passing 3 set of values to UDF say A, B, each contains around 10 values.

I want to check C agianest B i.e if b conatins all the c values then UDF need to return A values.

I want to check c(array) against b(array) and needs to return a(array).

Thanks,

Rishik.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can select Context or Queue option while creating the UDF.

In UDF use for loop on value B.

for logic:

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

{

if (B<i>.value == C<i>.value)

{

temp<i> = A<i>.value;

}

}

return temp;

I think this should work.

Thanks,

Hetal

Former Member
0 Kudos

Hi Hethal,

Thanks for your quick reply but, that udf is not working, I have around 5 different values in C and I want to Chech tem aginest B which has around 50 Values and then needs to populates A Values.

Thanks,

Rishik.

former_member204873
Contributor
0 Kudos

try:

String A[]= {"rr","rr"}; -- input

String B[]= {"rr","rrt"}; -- input

String C[]= {"rr","rru"}; -- input

int blen = B.length;

int clen = C.length;

int comp = 0;

for (int x = 0; x<clen;x++){

for (int y = 0; y<blen;y++){

if(B[y].equals(C[x])){

comp ++;

break;

}

else{

comp = blen + 1;

}

}

}

if(comp == blen){

result.addValue(A); -- U may have to use loop here

}

else{

}

Former Member
0 Kudos

Hi Rishik,

Use this below code

clen=c.len

int count =0;

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

{

for(int j=0; j< c.length; j++)

if(c[j].equals(b<i>)) count++;

}

if(count == clen)

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

{

result.addValue(c[k]);

result.addValue(ResultList.SUPPRESS); // use this if you want context change

}

else

{

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

result.addValue(""); // write what you want to pass if all the values of C array are not in B

}

Regards

Ramesh

Former Member
0 Kudos

Hi Ramesh,

Thanks for your reply

please see my current UDF and Mapping

Mapping http://tinypic.com/view.php?pic=2zrdif5&s=6

UDF

http://tinypic.com/r/2le6ot4/6

I want to get 2 5 3 1 as one set of pricing condition by omitting PF and then 2 5 1 as one set by omitting PP, right now I am getting too many suppress's which changing my context.

Thanks,

Rishik.

Edited by: Rishik on Jul 1, 2010 12:21 PM

Former Member
0 Kudos

Hi Rishik.

I am unable to view the code properly, copy your udf code.

check my code if it is working fine then use that one.

Regards

Ramesh

Former Member
0 Kudos

Hi Ramesh,

Right I am not in office, so I couldn't able to test it, but please see my code and let me know if I need any changes to this.



for (int x = 0; x < c.length; x++){
  for(int y = 0; y < a.length; y++){
	if(!a[y].equals ("PP"))
	{
		if(!a[y].equals ("PF"))
		{
		if(c[x].equals (b[y]))
		{
		result.addValue(a[y]);
		}
		}else{
		if (y != 0)
		{
		result.addContextChange();
		}
		}
	}else{
		if (y != 0)
		{
		result.addContextChange();
		}
		}
}
}

Thanks,

Rishik.

Former Member
0 Kudos

Rishik,

i am not clear your requirement, why you are checking PP and PF values?

could you pleae eloborate your requirement and provide me the input and expected output array values also.

> if(!a[y].equals ("PP"))

> {

> if(!a[y].equals ("PF"))

BR

Ramesh

Former Member
0 Kudos

Hi Ramesh,

input values say( Values differ in each scenario, but I want to check C always against B and returns A)

array A: ( Always contains PF and PP Values and ecah PF and PP contains respective 1 2 3 5's)


Array A	    Array B	    Array C	       Result
1	        181602	188331	
PF	        188331	181938	
2	        188331		               2
3	        188331		               3
5	        188331		               5
1	        188331		               1
PP	        181938		
2	        181938		               2
5	        181938		               5
1	        181938		               1

by omitting first 1 PF PP in arra A ( I need to get 2 3 5 1 of PF by omitting PF same with PP)

Thanks,

Rishik.

Edited by: Rishik on Jul 1, 2010 1:28 PM

Edited by: Rishik on Jul 1, 2010 1:32 PM

Edited by: Rishik on Jul 1, 2010 1:34 PM

Edited by: Rishik on Jul 1, 2010 1:36 PM

Former Member
0 Kudos

Hi,

Use this below code

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

{

for(int j=0; j<b.length; j++)

{

if(c<i>.equals(b[j]))

{

if(!((a[j].equals("PF")) || (a[j].equals("PP"))))

result.addValue(a[j]);

else result.addValue(""); // if the condition is true means equals PF or PP then sending space

}

}

result.addValue(ResultList.CC);

}

Regards

Ramesh

Former Member
0 Kudos

Thanks Ramesh, I will let you know tomorrow how it goes