AutoSys Workload Automation

  • 1.  Javascript for job frequency

    Posted Jul 18, 2018 06:35 AM

    I'm working on scheduling a job on 3rd calendar day of each month.

    If 3rd calendar day falls on Sat, Sun or public holiday, run next working day.

    The application working days is Mon to Sat (except public holiday).  I cannot use the normal way in the menu to handle.  Would like to seek whether JavaScript can help in the job frequency.

     

    Using CA Workload Automation DE r12



  • 2.  Re: Javascript for job frequency

    Posted Jul 18, 2018 10:03 AM

    Hi, 

    I would think coding the JavaScript would be difficult at best.  Below is an alternative thought.....

    ***************************************************************************************************************************

     

    The appl is currently scheduled on a calendar that has workdays defined as Mon-Sat less holidays

    I doubt in this scenario that Saturday will ever be a holiday. In this case jobs are really running Mon-Friday less holidays and also on Saturday. So make this application run on a normal Monday - Friday workday calendar and code the jobs with "Run workdays" and "Run Saturday". 

    Then it is easy to add the job to run on the 3RD DAY OF MONTH PLUS 0 WORKDAYS. If the 3rd falls on Saturday, Sunday or a Holiday it will roll/move to the next workday. 

    Let me know if you have any questions on this. 

     

     

    Just a thought.....

     

    Note:

    The jobs could also be scheduled on

    Run Monday Tuesday Wednesday Thursday Friday Saturday

    Do Not Run holidays

     

     

    Let me know if I missed the boat........just a thought.....



  • 3.  Re: Javascript for job frequency

    Posted Jul 19, 2018 03:23 AM

    Hi powdo03

    Your logic is correct.  However, the use of calendar seems one application mapping to one calendar only.

    In my case, 500 jobs use the default calendar with working day (mon-sat).  Only two jobs can use your way with the calendar working day (mon-fri).  How can I point these two jobs to another calendar provided that all the jobs are in the same application.  



  • 4.  Re: Javascript for job frequency

    Broadcom Employee
    Posted Jul 19, 2018 08:48 AM

    Hi,

    The event decides to pick up the job when application is getting ready or built.  The event will have time and day and only jobs matching the day criteria will be picked up.  If you have lots of job that are not dependent on other jobs, you can either move them to another application and setup the event.  Or you can setup another event that will pick up the jobs accordingly.

    Also, I would suggest to break up jobs in smaller applications.  Having 500 jobs in an application is not ideal, it leads to these kind of trigger issues and becomes very hard to debug as well.

     

    Thank you,

    Nitin Pande

    CA Technologies



  • 5.  Re: Javascript for job frequency

    Posted Jul 19, 2018 01:20 PM

    Hi, 

    Just to explain.... 

    In my scenario all 500 +1 jobs would run on the calendar defined with Workdays as Monday - Friday. 

    All 500 would all be defined with the two statements below.  

    Run Workdays

    Run Saturday.  

    The "3rd workday" job would be defined to run on "3RD DAY OF MONTH PLUS 0 WORKDAYS" 

     

    A note on my previous NOTE

    I actually prefer the run criteria to look like the statements below.  I don't like the use of WORKDAYS in the RUN statement in the job. When someone looks at a job definition I would like them to know when the job runs. When it says Workdays, someone then needs to go find what calendar the job runs on, and then they need to go to the calendar to see when workdays are defined in the calendar.  This leads to errors. 

     

    Run Monday Tuesday Wednesday Thursday Friday Saturday

    Do Not Run holidays

     

    This was just a thought...... writing the Javascript will not be easy/possible and will cause headaches down the road. 

     



  • 6.  Re: Javascript for job frequency

    Broadcom Employee
    Posted Jul 19, 2018 02:19 PM

    See if the javascript example at Event trigger time for the job would help, and use the %WOB.sched variable in job run frequency. Example;

    genTime('third','3rd day of month');
    if (thirdDAY=='Saturday' || thirdDAY=='Sunday')  
      WOB.sched='3rd day of month plus 0 workdays';
    else WOB.sched='3rd day of month';



  • 7.  Re: Javascript for job frequency

    Posted Jul 19, 2018 04:21 PM

    Hi, 

    I think the code looks more like the one below.  This should be tested thoroughly.... 

     

    genTime('one','3rd day of this month plus 0 workdays');
    WOB.Run3rd=oneDATE
    if (oneDAY=='Saturday'){
    genTime('one','4th day of this month plus 0 Workdays');
    WOB.Run3rd=oneDATE
    }

     

    The job contains

    Run %WOB.Run3rd

     



  • 8.  Re: Javascript for job frequency

    Posted Jul 22, 2018 09:15 PM

    Thx all for the hints.