Time Window Functions
The TMS Time Window Functions function set (codeunit 11237455) contains three functions that calculate and adjust the loading and unloading dates and times on an order or section based on a time window. Use them when you want 3PL Dynamics to move the requested dates and times to the first slot the time window actually allows, instead of only checking them.
Overview
| Function code | Use it to |
|---|---|
GET (UN)LOAD DT |
Move the loading and/or unloading date/time to the first available appointment slot of the matching time window line. |
GET UTC (UN)LOAD DT |
Do the same, but read the time window in the time zone of the address and write the result to the order in UTC. |
CHECK TRANSIT |
Recalculate the loading and/or unloading date/time with the date formulas and lead times of the matching time window line. |
All three functions run on the TMS document (the order or section) and use the same time window line matching as the rest of the time window logic. They find the line by the Time Window Code, the activity type, the sell-to customer, the from or to address, the order type, the item condition of the goods lines, the plan box, and the posting date of the order. Unlike the Check Time Window status function, they don't filter lines by the area of the address.
Add a time window function to a status template
- Open the status template of the order or section, and select the status on which the dates and times must be calculated.
- On the status line, choose the assist-edit button in the Execute Function Set field.
- Add a function set entry with
Codeunit ID11237455 (TMS Time Window Functions), and select one of the function codes inFunction Code. - On the Parameters tab, fill in the parameters described for the function below.
The following example shows a function set entry that calculates the unloading date/time with the time window DEFAULT and sets the order to status NO SLOT when no suitable date is found. The time window code and status are examples; use your own values.
{
"FunctionSet": {
"TableNo": 11172786,
"Entries": [
{
"EntryNo": "10000",
"CodeunitID": "11237455",
"FunctionCode": "GET (UN)LOAD DT",
"Description": "Get Loading / Unloading DateTime",
"Parameters": [
{
"ParameterName": "CODE",
"Value": "DEFAULT"
},
{
"ParameterName": "ACTIVITYTYPE",
"Value": "2"
},
{
"ParameterName": "NOT FOUND STATUS",
"Value": "NO SLOT"
}
]
}
]
}
}
Get loading or unloading date/time
Function code: GET (UN)LOAD DT
The function looks for the first available slot in the matching time window line and moves the loading and/or unloading date/time of the order to that slot.
- The function determines the date to start searching from: today (or the
REFERENCE DATE), with the line'sDate Formula Beforeapplied when the current time is before the line'sClosing Time, orDate Formula Afterwhen it's later. The start date is never earlier than theLoading Date FromorUnloading Date Fromalready on the order. - From that date, it checks each day, for up to one week, for a slot in the line's Appointment (Different from default) details that applies to the order.
- If
Respect Address Opening Hoursis enabled on the line and the address has opening hours set up (see Time Slot), the slot must also fall within the opening hours of the address. - If the line also has Opening Hours details that apply to the order, the slot is narrowed to the overlap with those opening hours.
- The function writes the slot to the order:
- The
Loading Date From/Unloading Date Fromis set to the date of the slot. TheLoading Time From/Unloading Time Fromis only moved to the start of the slot when the slot starts later than the time on the order, or when the order has no time yet. - The
Loading Date To/Unloading Date Toand times are set to the end of the slot. A slot that ends earlier than it starts is treated as an overnight slot and ends on the next day. - The previous dates are kept in
Requested Ending Date FromandRequested Ending Date To. - When the unloading date would fall before the new loading date, the unloading dates are moved to the loading dates.
- The
If no suitable slot is found within one week, the order gets the status from the NOT FOUND STATUS parameter, with the reason No suitable date found with Time Window [code]. Date limit reached: [date]. If you also fill in IRREGULAR CODE, an irregularity with that code and reason is created on the order.
Note
The function only finds a slot when the matching line has at least one Appointment (Different from default) detail that applies to the order. When no time window line matches the order, the dates and times on the order aren't changed.
| Parameter | Description |
|---|---|
CODE |
The time window to use. When you leave it blank, the default TMS time window is used. |
ACTIVITYTYPE |
The activity to calculate: 1 = Load, 2 = Unload, 3 = Both. |
NO DATE STATUS |
Listed as a parameter, but not used by the calculation. Use NOT FOUND STATUS instead. |
NOT FOUND STATUS |
The status to set on the order when no suitable slot is found within one week. |
IRREGULAR CODE |
The irregularity code to register when the status from NOT FOUND STATUS is set. |
REFERENCE DATE |
The date to calculate from instead of today. |
REFERENCE TIME |
The earliest time on the first day that is searched. Can only be used together with REFERENCE DATE; otherwise, an error is shown. |
Get loading or unloading date/time in UTC
Function code: GET UTC (UN)LOAD DT
This function works like GET (UN)LOAD DT and uses the same parameters, but it's meant for environments that use Multiple Time Zones in System on the Transport Setup. The time window details and the opening hours of the address are interpreted in the time zone of the address, and converted to UTC before they're written to the order.
The differences with GET (UN)LOAD DT are:
- The search on each day starts from the loading or unloading time already on the order, instead of from midnight. On the first day,
REFERENCE DATEandREFERENCE TIMEtake precedence when you use them. - The from and to times on the order are always overwritten with the calculated slot, instead of only when the slot starts later.
Check requested date/times with transit times
Function code: CHECK TRANSIT
The function recalculates the loading and/or unloading dates and times of the order with the date formulas and lead times of the matching time window line, so a long transit time automatically pushes the dates further out.
- The function finds the matching time window line, and the first Appointment (Different from default) detail and the first Opening Hours detail whose
Table Filterapplies to the order. An appointment detail takes the place of the line's own settings. - It determines whether the order was created before or after the
Closing Time, and chooses the start date based on theStarting Point Date: the requested date on the order, or the creation date of the order. A requested date earlier than the creation date is replaced by today. The unloading date is never earlier than the loading date. - For the from date and time, it applies
Date Formula Before(created before the closing time) orDate Formula After(created after), taking theBase Calendar Codeinto account, and moves the from time forward to theStarting Timewhen it's earlier. - For the to date and time, it does the same with
Date Formula Before LeadtimeorDate Formula After Leadtime, and moves the to time forward to theEnding Time. For an overnight window (theStarting Timeis later than theEnding Time), the to date is at least one day after the from date. - When an Opening Hours detail applies, its times and date formulas are applied on top of the result.
- The calculated dates and times are written to the order. The previous dates are kept in
Requested Starting Date FromandRequested Starting Date To.
| Parameter | Description |
|---|---|
CODE |
The time window to use. When you leave it blank, the default TMS time window is used. |
ACTIVITYTYPE |
The activity to calculate: 1 = Load, 2 = Unload, 3 = Both. |
NO DATE STATUS, NOT FOUND STATUS, IRREGULAR CODE |
Listed as parameters, but this function doesn't set a status or create an irregularity. |