if-else logic in tmap

One Star

if-else logic in tmap

hi guys,
I want to implement if else logic in expression builder in tmap.If i get an input string as "TRUE" i want to make it 1 in my output csv file or else if i get "FALSE" then i want to make it as 0 or else i want to make it as null.How to acheive this via tmap.Please Reply.Thanks in advance.
Regards,
Neeraj
One Star

Re: if-else logic in tmap

Hi neeraj,
You cannot use if then else explicitly in tMap, however you can use a java ternary expression. e.g. row1.field.equals("TRUE") ? 1 : 0
If you have to use if then else then use a tJavaRow or write a custom routine.
Regards,
Rick
One Star

Re: if-else logic in tmap

Hi,
I have tried with the same logic(row1.field.equals("TRUE") ? 1 : 0) but it is returning me only "0". please could any one help me on this?
Thanks in advance.
Regards,
Vetha.
One Star

Re: if-else logic in tmap

If you trying to print the value of row1.field  what does it prints? 

I have used it number of times and it has worked everytime.
One Star

Re: if-else logic in tmap

Hi,
The problem is with data type. now i have changed the data type of that field as "Boolean" and it is working fine.
Thanks.
Regards,
Vetha.