cancel
Showing results for 
Search instead for 
Did you mean: 

Nested IF condition

Former Member
0 Kudos

Hi Experts

Please help in understanding the below mapping

Source: XXX

Target : AAA

condition: if XXX = 123 then name 1

if XXX = 456 then name 2

if XXX = 789 then name 3

if XXX = 098 then name 4

else name 5

Regards

Lara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

one more suggestion..u can go for UDF also (However solution suggested by Mark is more simple)

input : var

execution type: single value


if(var.equals("123"))
{
return "name1";
}
 else if(var.equals("456"))
{
return "name2";
}
else if(var.equals("789"))
{
return "name3";
}
else if(var.equals("098"))
{
return "name4";
}
else
{
return "name5";
}

XXX-UDF--AAA

Former Member
0 Kudos

Hi Experts

Thanks for your answers shared, but the condition has changed to 3 instead of 4

Source: XXX

Target : AAA

if XXX=123 then name1

if XXX = 345 then name 2

if XXX = 456 then name 3

Regards

Lara

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can still use fixValues


Use default value when lookup fails
Default value: 
key         value
123      name1
345      name2
456      name3

Mapping will still be


Source -> fixValues -> Target

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark

thanks for your prompt response, I forgot to mention, there is no default value here.

Source: XXX

Target : AAA

if XXX=123 then name1

if XXX = 345 then name 2

if XXX = 456 then name 3

Regards

Lara

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can choose either pass value for the lookup fail behavior or throw an exception

Regards,

Mark

Former Member
0 Kudos

Hi Mark

Can't we do the same using if-else-then condition.

Here how i have done

if XXX=123 then name1

else

if xxx = 456 then name2

else

if xxx - 789 then name3 (ifwithoutelse condition)

Regards

Lara

Former Member
0 Kudos

>>Can't we do the same using if-else-then condition.

you can but in case if the condition increases then it will create a mess and ur mapping will become difficult to handle:)

why dont u go with the above suggested solutions(Fix value or UDF)??

rajasekhar_reddy14
Active Contributor
0 Kudos

Amit alreadt mention you can achieve this requirement using standard functions too,but you have to use multple standard functions -evry standard function is associated with java code so when you execute mapping program it executed all functions so it is kind of burden.

always try to follow best practises..in your case go for fix value table,in future if you want to add more conditions then adding entries in fix value table is simple.

Regards,

Raj

Former Member
0 Kudos

HI Experts

Thank you all, the problem is solved

Regards

Lara

Answers (2)

Answers (2)

Former Member
0 Kudos
markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can use fix values for your requirement


Use default value when lookup fails
Default value: name5
key         value
123      name1
456      name2
789      name3
098      name4


Source -> fixValues -> target

Hope this helps,

Mark