DAY SHIFTING IN CPS JOB SCHEDULE
Calendar time windows in CPS job scheduler allow us to shift days forward or backward. This could be useful to compensate public holidays or when our job run falls on a weekend. It could be possible to compensate for that by shifting a process a few working days forward or backward.
This works by comparing two time windows, the reference is the calendar time window, if an open day of that time window is closed in the Enabled Or Shift Calendar time window, then the process is shifted forward or backward according to a third time window.
For instance, a job has to run on every 5th working day of the month, i.e., excluding weekends. If the job falls on a weekend, it moves forward and runs on the next weekday.
The below steps have to be executed:
Create Time Window “TW_WEEKDAY”
For a start, create a time window in the main partition for only weekdays, named “TW_WEEKDAY”, keeping open dates only for Monday to Friday.
In the “TIME WINDOW” tab, give the names & description of the newly created time window.
Mark the “is calendar” column.
Goto the “ELEMENTS” tab, add an element and mention the description and the details as below:
In the row “and from the”, mention “Monday” of the month and in the row “and until the”, mention “Friday” of the month.
This way, we are restricting the window to be open only from Monday to Friday.
Goto the “OPENS AT” tab and verify if the window is open only for the mentioned period and not during weekends.
Check for the current & the future months.
Once verified, the time window could be saved, click on “SAVE & CLOSE” at the bottom.
Create Time Window “TW_5TH_WORKINGDAY”
Following the same procedure as in TW_WEEKDAY, create another time window named “TW_5TH_WORKINGDAY”.
This Time window serves the main purpose of our job that has to run every 5th working day of the month.
Provide the details in the “TIME WINDOW” tab including name of the window, description and mark “Is Calendar” column.
Goto the “ELEMENTS” tab, add an element and mention the details as below:
In the row “and from the”, mention “5th” until the “5th” day of the month.
This is to ensure that the primary condition of the window is to run on 5th day of each month.
SPECIFY THE OPEN-CLOSE CONDITION
In the same time window “TW_5TH_WORKINGDAY”, go back again to the “TIME WINDOW” tab and at the bottom few conditions have to be specified.
Fill in the conditions:
“If an open day is closed during”, mention the time window “TW_WEEKDAY”,
“then shift this day”, here we can mention either forward or backward,
“to the”, mention “1” or any number of days that we want the job to be shifted,
“open day in”, mention “TW_WEEKDAY”.
Open days in TW_WEEKDAY are from Monday to Friday for all months and open days in TW_5TH_WORKINGDAY are 5th day of every month.
The logic behind this is that if an open day in the TW_5TH_WORKINGDAY, is closed in “TW_WEEKDAY”, this condition holds true only during a weekend, when the 5th of the month falls on a Saturday or Sunday, we could preferably prepone or postpone the job to the next desired working day.
So go ahead and give the number of days the job needs to be shifted, and consider the next open day as in “TW_WEEKDAY”.
Goto the “OPENS AT” tab of the current time window and verify if the open days are co-relating with the condition given.
Open days in Jun are “5th” and it falls on a working day:
Going ahead, if we check for Oct, 5th falls on a weekend, so the job run shifts forward to the next day in TW_WEEKDAY, hence to “7th OCT”
Hence our time window responds fine.
SUBMIT THE JOB AS A FINAL STEP
Goto the job that has to be submitted in the respective partition, in job definition, right click on the job and click submit.
In “PARAMETERS” tab, specify the parameters, system and the client, verify other details as well.
In the “TIME & DATES” tab, specify time window as “TW_5TH_WORKINGDAY”.
Set the frequency as “Daily”, so that the job run calculates daily as per the specified time window. This is very essential and do not specify the frequency as “Monthly” here.
In “Scheduling” tab, mention the queue name, and then goto “submit summary”.
Verify the dates for the job to run for the future months too, to make sure that the job shifts when it falls on a weekend.
Finally, click on submit at the bottom.
Similar method can be used if we need to schedule a job that has to shift if it falls on a public holiday.
We create three time windows, the first is closed on Public Holidays (TW_CLOSED) the second is open Monday to Friday (TW_WEEKDAY), the third is our job’s calendar time window (TW_CAL), it is open on the required day, say the last day of the month.
So the condition would be when an open day in TW_CAL is closed in TW_CLOSED, then we shift the process to the preceding/next open day in TW_WEEKDAY