cancel
Showing results for 
Search instead for 
Did you mean: 

mapping condition.

Former Member
0 Kudos

Hi all,

In my mapping; in source message type one field called f1 and in target message type another field called f2. f1 should be mapped to f2 in such a way as below....

if f1 = 4 then f2 = A

else if f1 = 1 then f2 = B

else if f1 = 0 then f2 = C.

What should I do for this.Are there any mapping logics available for this?

Can anybody pleaseeee.........

Thanks & Regards,

Radhika.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Radhika,

Either you can use Value Mapping or Fix Value Mapping.

Simplest way would be use function "FixValues" under category Converions.

If you double click on the the function it will ask you for Key and corresponding value...in key you can put 1,2,3.....and value would be mapping value. i.e. A,B,C...

Let me know if you needmore details.

Nilesh

Former Member
0 Kudos

Using the Fixed Value Mapping would be easier, as has been suggested.

Answers (5)

Answers (5)

former_member267355
Active Participant
0 Kudos

Hi Radhika,

You can use user defined function for this, code is as below

String b;

if(a.equals("4"))

return b= "A";

else if (a.equals("1"))

return b="B";

else if (a.equals("0"))

return b="C";

else return a;

you can copy & paste in your user defined fn., map it with your source & target field

it will work as you expect.

Regards,

Sakthi

justin_santhanam
Active Contributor
0 Kudos

Radhika,

Choose any one of the pattern from the below links.

Pattern1

http://www.flickr.com/photo_zoom.gne?id=1138043932&size=o

Pattern2

http://www.flickr.com/photo_zoom.gne?id=1138043938&size=o

Best regards,

raj.

Former Member
0 Kudos

hi radhika,

As all said u approach in that way but we have a flexibilty to write user defined functions .so I sugget you to go for UDF in that write the switch --case it works fine no need for complex mappings.

Reward if useful,

Srinivas.D

Former Member
0 Kudos

Hi Radhika !

And another alternative to what Nilesh proposes is if you need to translate a lot of values or they could change with some frequency, you could use the ValueMapping function that uses values entered in Configuration to map values..this avoids to make transports of repository objects once you are in production environment.

Regards,

Matias.

Former Member
0 Kudos

Hi Radhika !

You should use the If-Then-Else function and some constants to create the "A","B" and "C" values for the target, and for comparing f1 values. Also the equalS function to compare the f1 source field with a constant value.

You will need to use 2 if-then-else functions of graphical mapping.

This function has 3 inputs and 1 output. The inputs are

1) a boolean value

2) a value that goes to the output when 1) is true

3) a value that goes to the output when 1) is false

the equalS function returns true if the 2 input strings are equal. Use this function to compare f1 with the constant values and use the output of this function as input for the if-then-else function.

If you have any question, please ask.

Regards,

Matias.

Message was edited by:

Matias Denker

Former Member
0 Kudos

Hi,

But 4 is not a boolean number as 0 and 1...How is it possible with 4?

Former Member
0 Kudos

Hi Radhika !

You should use "equalS" to compare the content of "f1" with the constant "4"..this function will return "true" if content of "f1" is "4" and false if it is not. This boolean output is what you should use as input for the "if-then-else" function, because this later function only accepts boolean input or "0"/"1".

Regards,

Matias.

Former Member
0 Kudos

Hi Matias ,

So one of my "if-then-else" function output should be the input for the "if" node or "else" node of another "if-then-else" function...am I Correct??

Former Member
0 Kudos

Radhika,

Did you tried FixMapping function...it is quite easy if you have more than 2-3 conversion values..in future you can add more values..without actually changing code..

Nilesh

Former Member
0 Kudos

Hi Radhika !

This is one of the patterns.

http://img443.imageshack.us/img443/6155/drawing1cau0.jpg

Regards,

Matias.