Four Stars

How to pass context variable value from TAC to a job?

I have 2 jobs setup in TAC, one runs at night and one runs at daytime.    When 1st job runs, it should pass a value 'A' and 2nd job runs, it should pass a value 'I'.  Context variable is called PassRunValue.

Inside both of these two jobs, I've defined the context variable PassRunValue = "A" for job1

and PassRunValue = "I"  for job2.

 

How can we pass the value from TAC to the a job?

 

my job has 

tjava--->if 'A'--->tmssqlinput--->tlogrow

tjava--->if 'I''--->tmssqlinput--->tmssqloutput

 

Currently tjava contains:  context.PassRunValue = "";

4 REPLIES
Six Stars

Re: How to pass context variable value from TAC to a job?

I don't know how to make that work, if I'm understanding your setup correctly.

 

I have a job that has to run at midnight before some other jobs that run every hour. I have a tJava component that sets the context variable "isMidnight", and I use "run if" links from it to choose a different set of subjobs to run based on the time.

Four Stars

Re: How to pass context variable value from TAC to a job?

Can you show the setup with the screen shot. I'm trying to see how you are setting  context variable "isMidnight".

Six Stars

Re: How to pass context variable value from TAC to a job?

Here's the if logic

runIfSample.PNG

The "InitializeContext" tJava component contains:

ZonedDateTime thisHour = ZonedDateTime.now(ZoneId.of("US/Pacific")).truncatedTo(ChronoUnit.HOURS);
context.isMidnight = thisHour.getHour() == 0;

The "Run if" conditions are then just simply "context.isMidnight" and "!context.isMidnight". This is the Stackoverflow post with the general approach:

https://stackoverflow.com/questions/24504935/skip-a-component-based-on-condition-in-talend

 

Four Stars

Re: How to pass context variable value from TAC to a job?

I'm trying to understand, when I pass the value for PassRunValue variable from TAC, does it overwrite the value set in tjava?

 

1.  Passing PassRunValue = "A" from TAC

2.  Job has tjava component, which has value of  context.PassRunValue = "";

3.  Would tjava component set the context variable context.PassRunValue = "A" ?