Shifting Times and Days with Time Windows
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 function SAP_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. - Choose 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.
- Choose Save & Close.