tJava - IF ELSE statement fails!

Highlighted
Nine Stars

tJava - IF ELSE statement fails!

I run SQL and pass the result of "STOP or "GO" to tMap and then tContextLoad:

 

tTeradataInput > tMap > tContextLoad

˅

OnSubjobOK

˅

tJava

 

The tJava code is:

System.out.println( "Context variable value is:"+context.myCHECK);

 

globalMap.put("myCHECK", context.myCHECK);
System.out.println( "Global variable value is:"+globalMap.get("myCHECK"));

 

if(globalMap.get("myCHECK")=="STOP"){System.exit(99);}else{ System.out.println("START GOING NOW");}

 

System.out.println("FAILED TO STOP");

 

 

The result is correct when the context variable is GO:

Context variable value is:GO
Global variable value is:GO
START GOING NOW
FAILED TO STOP

 

But when the context variable is STOP the exit command doesn't trigger:
Context variable value is: STOP
Global variable value is: STOP
START GOING NOW
FAILED TO STOP

 

Any ideas how to make the if else statement actually exit the job?


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: tJava - IF ELSE statement fails!

Hi,

Replace the "if" statement like this:

if(((String)globalMap.get("myCHECK")).equals("STOP")) System.exit(99);
System.out.println("START GOING NOW"); // no else require

 


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: tJava - IF ELSE statement fails!

Hi,

Replace the "if" statement like this:

if(((String)globalMap.get("myCHECK")).equals("STOP")) System.exit(99);
System.out.println("START GOING NOW"); // no else require

 


TRF
Nine Stars

Re: tJava - IF ELSE statement fails!

Thanks!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now