Former Member

# mapping help

Need help on a mapping issue I have:

Have a field in source:

source 0..2 so this field repeats 3 times

source[1] contains value 1

source[2] contains value 2

source[3] contains value 3.

value 3 will always come so if value 1 and value 2 are not coming then value 3 will come in source[1]....

i have to map value 3 into output l1 field.

value 1 and value 2 if coming should be concatenated and mapped to l2 on the output.

I am having problems solving this.

10|10000 characters needed characters exceeded

• Former Member
Apr 05, 2010 at 09:03 PM

Hi Kumar,

Check if value3 exists. If exists then send value3 else value1 or value 2 will definitely exist. So do a concat with value1 and 2 which should be straight forward mapping.

Regards,

---Satish

10|10000 characters needed characters exceeded
• Apr 05, 2010 at 09:50 PM

If I understood your requirement right,

use exists function on value1 and value2 if you get false for both of them (do an AND) then map Value 3 to I1, else concat Value1 and value2 to I1.

Map I2 to Value 1 and Value2 concatenated. If they exist it will be filled.

VJ

10|10000 characters needed characters exceeded
• Former Member
Apr 05, 2010 at 09:55 PM

Kumar,

Since value 3 always exists you don't need to worry about it. for value 1 and value 2 just check with "If exists" and "create" node functions to determine whether the values exist or not.

Regards,

Pavan

10|10000 characters needed characters exceeded
• Former Member

How do I check if a field is coming for a second time or a third time?? If there is source field coming for the second time then I will get value 2.

Value 3 will always come but if value 1 or 2 is coming then source field will be repeated 3 times and third instance of source should be mapped to get the value 3 but I am having problems checking how many times the source field is repeating.

Thanks

• Former Member
Apr 06, 2010 at 10:43 AM

Hi Kumar,

Correct me if my understandin is Wrong.

You have one field(source),which can can repeat 3 times ..source[0]=val1 source[1] =val2 and source[2]=val 3

Is the val(1-3) constants?

Please try writing a UDF and take one input as a string array to the UDF.

put a for loop with itteration of 3 (asuming only 3 values will come).

read each value in to a temp var , check for value 2 and value 1 exsitance.if not then output the value which exsits , it v1 and v2 present concat and return the concat value.

if you need to send two values then put a delimiter(,), after udf split and map to out1 and out 2.

Regards,

srinivas

10|10000 characters needed characters exceeded
• > Please try writing a UDF and take one input as a string array to the UDF.

> put a for loop with itteration of 3 (asuming only 3 values will come).

> read each value in to a temp var , check for value 2 and value 1 exsitance.if not then output the value which exsits , it v1 and v2 present concat and return the concat value.

> if you need to send two values then put a delimiter(,), after udf split and map to out1 and out 2.

Better write two UDFs