cancel
Showing results for 
Search instead for 
Did you mean: 

mapping help

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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

Former Member
0 Kudos

hi Srinivas

Yes you are right, I have one field in the source structure repeating 3 times.

val1, val2 and val3 are not constants.

source field is of 40 char length. Val 1 and Val2 are street values. So if there is a Street value and if the value is more than 40 chars then val1 and val2 are generated meaning the source field will repeat twice(if its less than 40 chars then only Val1 will come). Val3 contains Location value and irrespective of whether va1 and val2 coming or not Val3(location) value will always come.

In the output I need to map val3(location) to Location field and depending on if Val1 and Val2 coming I need to concat and map to Street.field. In order to do this I need to know the correct instance of the source field being repeated.

Thanks.

stefan_grube
Active Contributor
0 Kudos

> 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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

VijayKonam
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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