Table of Contents

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

  1. Open the status template of the order or section, and select the status on which the dates and times must be calculated.
  2. On the status line, choose the assist-edit button in the Execute Function Set field.
  3. Add a function set entry with Codeunit ID 11237455 (TMS Time Window Functions), and select one of the function codes in Function Code.
  4. 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.

  1. The function determines the date to start searching from: today (or the REFERENCE DATE), with the line's Date Formula Before applied when the current time is before the line's Closing Time, or Date Formula After when it's later. The start date is never earlier than the Loading Date From or Unloading Date From already on the order.
  2. 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.
  3. If Respect Address Opening Hours is 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.
  4. If the line also has Opening Hours details that apply to the order, the slot is narrowed to the overlap with those opening hours.
  5. The function writes the slot to the order:
    • The Loading Date From/Unloading Date From is set to the date of the slot. The Loading Time From/Unloading Time From is 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 To and 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 From and Requested Ending Date To.
    • When the unloading date would fall before the new loading date, the unloading dates are moved to the loading dates.

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 DATE and REFERENCE TIME take 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.

  1. The function finds the matching time window line, and the first Appointment (Different from default) detail and the first Opening Hours detail whose Table Filter applies to the order. An appointment detail takes the place of the line's own settings.
  2. It determines whether the order was created before or after the Closing Time, and chooses the start date based on the Starting 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.
  3. For the from date and time, it applies Date Formula Before (created before the closing time) or Date Formula After (created after), taking the Base Calendar Code into account, and moves the from time forward to the Starting Time when it's earlier.
  4. For the to date and time, it does the same with Date Formula Before Leadtime or Date Formula After Leadtime, and moves the to time forward to the Ending Time. For an overnight window (the Starting Time is later than the Ending Time), the to date is at least one day after the from date.
  5. When an Opening Hours detail applies, its times and date formulas are applied on top of the result.
  6. The calculated dates and times are written to the order. The previous dates are kept in Requested Starting Date From and Requested 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.