Six 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?

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Eleven Stars TRF
Eleven 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
2 REPLIES
Eleven Stars TRF
Eleven 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
Six Stars

Re: tJava - IF ELSE statement fails!

Thanks!