Time Window Shifting
You can use Time Windows to shift times or days, to take custom calendars or public holidays into account when scheduling repetitive processes.
Time Shifting
Time Windows allow you to shift the time that a day starts. The Dutch railway company, for example, decided that for their schedule, the night from Friday to Saturday is still Friday. Saturday starts at 6 AM. Therefore, they want to specify that a process that is submitted for Friday 4 AM, actually runs on Saturday 4 AM. This can be achieved by using the _OffsetTimeOfDay _ attribute of Time Window elements. Note that the start time of processes will only be modified when OffsetTimeOfDay > Scheduled Start Time. For example, if the Dutch railway schedule a processes for execution at midnight with a Time Window, which has an OffsetTimeOfDay set to 6 AM, the process will actually run the following day at 6AM.
In previous releases (version 6 and 7), this behavior could be specified using the "wrap-functionality". When the From -time was greater than the To -time, the wrap-functionality was available. For example, an element could be 18:00 - 08:00 wrap
.
To convert a - b
wrap (note that a > b
), proceed as follows:
FromTime = a - b
ToTime = null, indicating end of day
OffsetTimeOfDay= b
To convert Thursday 18:00 - 08:00
wrap, disabled during Fridays:
FromTime = 18:00 - 8:00 = 10:00
ToTime = null
OffsetTimeOfDay = 8:00.
Note: The wrapped part of the time interval is always open if the Time Window was open at the beginning of the time interval. This without regard of other attributes of the Time Window. This behavior has not changed from version 7 and earlier.
Day Shifting
Day shifting is a feature that allows you to move a certain amount of days forward or backward when criteria are met. Day shifting requires that Time Windows be Calendar Time Windows.
Calendar Time Windows are normal Time Windows with the restriction that they do not specify times; they are always open for the whole day and allow you to shift days forward or backward.
Simple Day Shifting
You can shift a specified amount of days forward or backward by specifying the and shift open periods field on a Time Window element. Note that this shift counts actual days, if you want to only count workdays, for example, you need to use Paced Day Shifting described below.
The shift is relative to the range of days the Time Window element is open. For example, if your Time Window element is open from the 1st to the 3rd day of a month and the shift is 1, the element will be open from 3rd until the 6th day of the month.
Paced Day Shifting
This allows you to compensate public holidays or when the last day of the month falls a Sunday, for example. You can 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 main Time Window, if an open day of that Time Window is closed in the Shift Time Window, then the process is shifted forward or backward according to a third Time Window. The second ( Shift ) Time Window specifies when to shift (when the Shift Time Window is closed), the third ( Stride ) Time Window, defines the stride of the shift ( n number of open days), the number of steps to move ( n ) is defined in the main Time Window.
For example, your process runs on the last day of the month, when this is a weekday (Mon-Fri). When the last day of the month is a Saturday, Sunday or public holiday, you want to shift that process to the preceding workday.
You create three Calendar Time Windows, the first is closed on Public Holidays and is named TW_Closed, the second is open Monday to Friday and is named TW_WeekDay, the third is your main Time Window named TW_Cal, it is open on the last day of the month, when an open day in TW_Cal is closed in TW_Closed then we shift the process to the preceding open day in TW_WeekDay.
Another example, your process runs on the 3rd workday of every month according to the FR factory calendar in your SAP system.
You create 3 Calendar Time Windows. A Time Window that is always closed, named PR5_NEVER. A PR5_FR Time Window, which is defined by the period functionSAP_FactoryCalendar, it will need the following parameters: calendar = PR5 FR
. Redwood Server will use that Time Window to move forward according to the factory calendar. A Time Window PR5_3RD_WORKDAY with a Time Window element "on the last day of the month" and the shift condition "If an open day is closed during PR5_NEVER then shift this day forward to the 3rd following open day in PR5_FR".
Calendar Time Windows have the following restrictions:
On the Calendar Time Window:
- All referenced Time Windows must be calendars.
- Time zone cannot be set.
On elements of a Calendar Time Window:
- All referenced Time Windows must be calendars.
- Date From and Date To cannot be set.
- Time of Day From and Time of Day To cannot be set.
- Time zone cannot be set.
Calendar Time Windows are evaluated in the time zone of the process. The time zone of the process is the time zone specified in the Submit Wizard. When the process was submitted from RedwoodScript, without specific time zone, the central Redwood Server time zone is used for the process time zone.
Example
3rd workday according to FR factory calendar of SAP system PR5
- Navigate to Definitions > Processes.
- Submit SAP_ImportCalendars for SAP System
PR5
and SAP Calendar Typefactory
. - Choose Submit.
- Navigate to "Environment > Time Windows".
- Choose New Time Window from the context menu.
- Fill
PR5_Never
into the Name field. - Select is Calendar and choose Save & Close.
- Note that since we did not specify any details about when the Time Window opens, it is always closed.
- Choose New Time Window from the context menu.
- Fill
PR5_FR
into the Name field. - Select is Calendar.
- On the Elements tab, choose Add, and select SAP_FactoryCalendar in the period function, fill
calendar = PR5 FR
into the with parameters field. - Click Save & Close.
- Choose New Time Window from the context menu.
- Fill
PR5_3RD_WorkDay
into the Name field. - Select is Calendar.
- Select PR5_Never in the If an open day is closed during field.
- Select Forward in the then shift this day field.
- Fill
3
into the to the field. - Select PR5_FR in the open day in field.
- On the Elements tab, choose Add, and select last in the and from the field (6th line from the top), leave day of the month.
- Click Save & Close.