cancel
Showing results for 
Search instead for 
Did you mean: 

A Little Help Please

Former Member
0 Kudos

I have a UDF which is the following:

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

{

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

{

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

{

result.addValue(c[j]);

}

}

}

Now I have 3 inputs and 1 output as you can see. So my scenario is this.

In0 In1 In2 Out0

111 111 AAA AAA

222 333 CCC CCC

333

This is causing problems in my Mapping... I need the result to reflect th In0 Queue so My Out0 should look like this

AAA

Empty

CCC

Can you guys see what I am trying to achieve... I basicaly want my output values to occur in the same position in the queue that the in0 value occured and anything in between that doesnt have a match should appear as an empty string...

Please let me know how to do this or edit my UDF accordingly?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If a,b,c inputs are the same length , then you can achieve this , i mean if the a,b are equal no of inputs , then , if the c also contains the equal no of values then you can get the c(index) respective index value will be assigned to the result, other wise ww would have to check and add the empty value / constant value to be assigned to the result.

Regards

Chilla

Former Member
0 Kudos

Ahmad,

Thank you but we already tried this and it gives a result like

AAA

Empty

Empty

Empty

Empty

CCC

Chandra... Could you please give a code sample to illustrate what you mean

Message was edited by:

Ricardo Mendez

Former Member
0 Kudos

Hi,

Just try

In UDF select the type as Queue and see below

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

{

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

{

if(a.equals(b[j]))

{

result.addValue(c[j]);

break;// to come out from loop

}

else

{

result.addValue("Empty");

break; // to come out from loop

}

}

}

Regards

Chilla

Former Member
0 Kudos

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

{

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

{

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

{

result.addValue(c[j]);

break;

}

else

{

result.addValue("");

break;

}

}

}

Chandra I tried this but i added <i> to the a.equals

and still there is an issue... now I get

AAA

Empty

Empty

Former Member
0 Kudos

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

{

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

{

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

{

result.addValue(c[j]);

break;

}

else

{

result.addValue("");

break;

}

}

}

Chandra I tried this but i added <i> to the a.equals

and still there is an issue... now I get

AAA

Empty

Empty

Former Member
0 Kudos

if you want to have the values of In0 in the same order they appeared, you have to set the empty string in case nothing was found in the outer loop where you go over In0.

String res = null;

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

{

res = "Empty";

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

{

if(a.equals(b[j]))

{

res = a[j];

break;

}

}

result.addValue(res);

}

in this case the string res will be Empty unless a match is encountered and the string is altered. then after comparing each item in a with all items in b, the String is added to the result, so either it has a value or "Empty".

Regards

Christine

prabhu_s2
Active Contributor
0 Kudos

hi ricardo

i'm not much clear with ur post but i assume that u want to remove the context. try to map the outut of the UDF to remove context or splitbyvalue and check if the desired result is achieved

thkx

Prabhu

Former Member
0 Kudos

Hey

try using the bewlo code

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

{

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

{

if(a.equals(b[j]))

{

result.addValue(c[j]);

}

else

{

result.addValue("Empty");

}

}

}

Thanx

Ahmad