on 07-01-2010 12:42 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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{
}
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
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
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.
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
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.