Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am trying to achieve if else statement in tMap as follows. Using 5.6.1 talend version
Condition 1. If status = P then print the following values MOD,STK,ALG
(Sub Condition is
IF ALG is not null then print ALG then ignore ALG field completely.)
Expected output
if STATUS =p and ALG is not null
MOD=Sample_module;STK=Sample_stk;ALG=test;
if STATUS =p and ALG is null
MOD=Sample_module;STK=Sample_stk
if STATUS not equal to p then blank
(STATUS ).equals("P")?
("MOD="+"Sample_module;"+ ";STK="+"Sample_stk;"+
((ALG != null)? ("ALG="+ ALG):--false): " "
Please help to achieve this.
Based on your screen capture, as you're using a ternary condition, you need the "else" part.
General syntax is "your_condition ? then_part_expression : else_part_expression"
Also, at runtime a possible cause of null pointer exception is row2.STATUS is null.
So, start the condition with "P".equals(row2.STATUS) ? ...
Thanks TRF,
Is there any other alternative way to achieve this without using the ternary operator. As in my requirement , I don't have the else part.
If condition is not matching then the field should not be printed completely. So only If condition should be there.
Thanks