Automic Workload Automation

 View Only

 Waiting condition to trigger a task in a workflow

Mylene Chalut's profile image
Mylene Chalut posted Nov 22, 2021 04:04 PM

Hello,

I have a workflow that runs every day in all of our environments (Dev, Test, QA and Prod).  The workflow starts at 10pm and takes much longer to execute in Dev and Test than QA and Prod.  

I would like to add a JOBS to the workflow.  However, that task has to start the day after the workflow activation time (min 12:01 AM).

The condition would be:

If JOBS start_time = JOBP activation_time
    delay until 12:01
Else execute

What is the best way to do this ?

Thanks in advance for your help :-)

Mylene

Christoph Rekers's profile image
Christoph Rekers
Hi @Mylene Chalut,

what about "Earliest Starttime"?




Cheers
Christoph 

Mylene Chalut's profile image
Mylene Chalut
@Christoph Rekers Yes that would work, but what if the jobs is being triggered after midnight ? Then the job would start the next day at 12:01 AM...  no ?.  That is my issue...  I don't know when the jobs will be triggered.  That is why I am saying...

If JOBS start_time = JOBP activation_time (parent)
    delay until 12:01
Else execute
Christoph Rekers's profile image
Christoph Rekers
Hi @Mylene Chalut

This should do the trick (the SCRI needs to be generated at runtime)



Let me know if it works ;-)
Cheers
Christoph ​​
Mylene Chalut's profile image
Mylene Chalut

@Christoph Rekers   I was on the right path !!

I corrected my script with what you sent me, and I get a very weird error !!

First of all, I setup my workflow as you indicated.  Here is my script...

!! GET PARENT OBJECT ID
:SET &PARENTID# = SYS_ACT_PARENT_NR()
:PRINT &PARENTID#
:PRINT &JOB_ACT_DATE#
:PRINT &$PHYS_DATE_YYYYMMDD#

!! COMPARE PARENT ACTIVATION DATE ASSIGNED IN JOBI.BR_GET_GENERIC_VARIABLES WITH ACTUAL DATE
:IF &JOB_ACT_DATE# > &$PHYS_DATE_YYYYMMDD#
:  print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE delayed until next day"
:ELSE
:  print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start now."
:  SET &RETCODE# = MODIFY_UC_OBJECT(&PARENTID#, EARLIEST_STARTTIME, "JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE","OFF")
:ENDIF


Please note that in this script, I wanted to test the "MODIFY_UC_OBJECT" command, so the condition is &JOB_ACT_DATE# > &$PHYS_DATE_YYYYMMDD#.  It didn't work !  Here is the information that I get in the ACT report of the script:

2021-11-25 07:54:14 - U00020206 Variable '&JOB_ACT_DATE#' was stored with value '20211125'.
2021-11-25 07:54:14 - U00020408 0023937292
2021-11-25 07:54:14 - U00020408 20211125
2021-11-25 07:54:14 - U00020408 20211125
2021-11-25 07:54:14 - U00020408 Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start now.
2021-11-25 07:54:14 - U00011112 Workflow 'JOBP.WIN.BR_UTILITY_EXPORT.DAILY.STATS.TO.SQLTABLE' (RunID: '0023937292') is not in an active status - no modifications allowed.


This doesn't make sense at all !!  See for yourself...


Do you have any idea of why the report would say that the workflow is inactive ?

Christoph Rekers's profile image
Christoph Rekers
Hi @Mylene Chalut,

You wrote that this is the script the JOBP runs:

!! GET PARENT OBJECT ID
:SET &PARENTID# = SYS_ACT_PARENT_NR()​
...

I havn't tested it, but I'm pretty sure that the JOBP can not do the MODIFY_UC_OBJECT. I think it's an object of the JOBP that needs to do the modification. 

Cheers
Christoph
Mylene Chalut's profile image
Mylene Chalut

@Christoph Rekers  Ok well I thought that's what you did...    Get ParentId of JOBP.NEW2 in your example.  This is what I did...




That is also what I found in the documentation:

https://oneautomation/AWIDOC1230/help.htm#Script/Reference/MODIFY_UC_OBJECT.htm?Highlight=MODIFY_UC_OBJECT

I will do some more research ;-)​

Ralf Schmidt's profile image
Ralf Schmidt
Hallo Mylene,

alternatively you can set the earliest start time in the JOBP.WIN.BR_UTILITY_EXPORT.DAILY.STATS.TO.SQLTABLE, have a look at SET_CONDITION "EARLIEST_START_TIME".

https://docs.automic.com/documentation/webhelp/english/ALL/components/DOCU/12.3/Automic%20Automation%20Guides/help.htm#Script/Reference/SET_CONDITION.htm?Highlight=EARLIEST_START_TIME


:IF &JOB_ACT_DATE# > &$PHYS_DATE_YYYYMMDD#
: print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE delayed until next day"
: PRINT '"EARLIEST_START_TIME"="01/12:01" was set.'
: SET_CONDITION "EARLIEST_START_TIME"="01/12:01"
:ELSE
: print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start now."
:ENDIF

The job should have set to activation to runtime.
The earliest start time definition in the job must not be set in this case.

Greetings
Ralf
Mylene Chalut's profile image
Mylene Chalut

@Ralf Schmidt Still no luck !

Error message :  ​U00020355 Runtime error in object 'JOBP.WIN.BR_UTILITY_EXPORT.DAILY.STATS.TO.SQLTABLE', line '00012'. A JCL line was found. This is only permitted in Jobs. Content: ' :IF 20211129 > 20211129'

I still cannot figure out why the first solution didn't work ! Error message Workflow Inactive when it was active!

Mylene Chalut's profile image
Mylene Chalut
I am sssoooo confused !!  I added code to validate the workflow was indeed active...


And it is active !!

2021-11-29 13:30:47 - U00020206 Variable '&JOB_ACT_DATE#' was stored with value '20211129'.
2021-11-29 13:30:47 - U00020206 Variable '&PREV_REFPERIOD#' was stored with value '202111'.
2021-11-29 13:30:47 - U00020206 Variable '&REFERENCEPERIOD#' was stored with value '202112'.
2021-11-29 13:30:47 - U00020408 0024050289
2021-11-29 13:30:47 - U00020408 JOBP.WIN.BR_UTILITY_EXPORT.DAILY.STATS.TO.SQLTABLE
2021-11-29 13:30:47 - U00020408 20211129
2021-11-29 13:30:47 - U00020408 20211129
2021-11-29 13:30:47 - U00020408 Y
2021-11-29 13:30:47 - U00020408 Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start now.
2021-11-29 13:30:47 - U00011112 Workflow 'JOBP.WIN.BR_UTILITY_EXPORT.DAILY.STATS.TO.SQLTABLE' (RunID: '0024050289') is not in an active status - no modifications allowed.


So why do I get that message ? Somebody can explain that to me ?

Ralf Schmidt's profile image
Ralf Schmidt
Hallo Mylene,

I have simulated this.

Please create a test procedure (in the test environment).
A JOBP with the following content:

:PSET &JOB_ACT_DATE# = SYS_DATE("YYYYMMDD")
:PRINT "Startdate: &JOB_ACT_DATE#"

And a JOBS with:

:PRINT "&JOB_ACT_DATE# : &$PHYS_DATE_YYYYMMDD#"
:IF &JOB_ACT_DATE# > &$PHYS_DATE_YYYYMMDD#
: print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE delayed until next day"
: PRINT '"EARLIEST_START_TIME"="01/12:01" was set.'
: SET_CONDITION "EARLIEST_START_TIME"="01/12:01"
:ELSE
: print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start today."
: PRINT '"EARLIEST_START_TIME"="00/12:01" was set.'
: SET_CONDITION "EARLIEST_START_TIME"="00/12:01"
:ENDIF

The JOBS needs here the generation at the activation time:

The result of the JOBS starttime:



Greetings Ralf

#################

Hello Mylene,

sorry, I have a thinking wrong here!!!

This is then always the current day, since activation at start time.

Shouldn't it just go when activation is enabled at start time, and the start time is specified?

Greetings Ralf


###

Hallo Mylene,

sorry for the confusion, but I have now found a solution.
The JOBS must be generated here for activation and be included in another JOBP with generation at runtime.
Then the JOBS is activated when the predecessor is finished.

Greetings Ralf​
Mylene Chalut's profile image
Mylene Chalut
@Ralf Schmidt The goal of all this is to...
If JOBS start_time = JOBP activation_time (parent) -- EQUAL DATE
    delay until 12:01
Else execute

So this code added in a SCRI object before the actual task in the workflow worked properly:
!! GET PARENT OBJECT ID
:SET &PARENTID# = SYS_ACT_PARENT_NR()
:PRINT &PARENTID#
:PRINT &JOB_ACT_DATE#
:PRINT &$PHYS_DATE_YYYYMMDD#

!! COMPARE PARENT ACTIVATION DATE ASSIGNED IN JOBI.BR_GET_GENERIC_VARIABLES WITH ACTUAL DATE
:IF &JOB_ACT_DATE# = &$PHYS_DATE_YYYYMMDD#
:  print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE delayed until next day"
:ELSE
:  print "Execution of JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE will start now."
:  SET &RETCODE# = MODIFY_UC_OBJECT(&PARENTID#, EARLIEST_STARTTIME, "JOBS.WIN.BR_SI_SURVEY.PROC_EXPORT.DAILY.STATS.TO.SQLTABLE","OFF")
:ENDIF

NOTE THAT THE PROPERTY OF THE TASK IN THE WORKFLOW IS SET TO...



So far, so good !!  It's working !!

But just for testing purposes...  to test the condition where I have to modify the turn off of EARLIEST_STARTTIME to off, I changed the condition to :
IF &JOB_ACT_DATE# > &$PHYS_DATE_YYYYMMDD#

That's when I realized that the MODIFY_UC_OBJECT was not running as expected (based on the information that I took from https://oneautomation/AWIDOC1230/help.htm#Script/Reference/MODIFY_UC_OBJECT.htm?Highlight=MODIFY_UC_OBJECT.  And frankly, logically, I don't understand why it's not working since my workflow IS INDEED ACTIVE, compare to what the error message is saying.  Is this a bug ?  Anyway, I have to make this work ! 

Mylene

Mylene

Christoph Rekers's profile image
Christoph Rekers
Hi @Mylene Chalut,

Does it work now? If not, could you export the 3 objects so that we can have a lock at it?

Cheers
Christoph
Mylene Chalut's profile image
Mylene Chalut

@Christoph Rekers / @Ralf Schmidt

I feel so stupid !!  The script add to be setup to generate at runtime.  Everything is working ​​now.  Thanks a lot to both of you for your help ;-)

Mylene Chalut's profile image
Mylene Chalut

@Christoph Rekers / @Ralf Schmidt

​​The script had to be set to be generated at runtime.  Everything is running as expected now.  Thanks a lot to both of you for your help ;-)