Purpose
The UNT (Message Trailer) segment closes every individual message within an EDIFACT interchange. Its primary role is to provide integrity checking: it contains a count of all segments in the message (including UNH and UNT themselves) and repeats the message reference number from the opening UNH segment. This allows receiving systems to verify that no segments were lost or added during transmission.
If the segment count in UNT does not match the actual number of segments received, or if the message reference number does not match the corresponding UNH, the receiving system should flag the message as potentially corrupted and may generate a CONTRL error report.
Data Elements
The UNT segment is straightforward, containing just two mandatory data elements:
- 0074 - Number of Segments in the Message: The total count of all segments in the message, starting from and including the UNH segment, up to and including the UNT segment itself. For example, a message with UNH, BGM, DTM, UNT would have a segment count of 4.
- 0062 - Message Reference Number: Must be identical to the message reference number specified in the corresponding UNH segment. This pairing ensures that every message is properly opened and closed.
Format and Syntax
The format of a UNT segment is simple and consistent:
UNT+segmentCount+messageReferenceNumber' The segment tag UNT is followed by the segment count and the message reference number, separated by the plus sign (+) element separator. The segment ends with the segment terminator.
Messages That Use UNT
Like UNH, the UNT segment is mandatory in every UN/EDIFACT message. It is always the last segment before either the next UNH (if the interchange contains multiple messages) or the UNZ interchange trailer. You will find UNT in every message type including:
- INVOIC (Invoice)
- ORDERS (Purchase Order)
- DESADV (Despatch Advice)
- CONTRL (Syntax and Service Report)
- PRICAT (Price/Sales Catalogue)
- REMADV (Remittance Advice)
Example
A UNT segment closing a message that contained 12 segments in total:
UNT+12+1' This tells the receiving system that the message referenced as 1 should contain exactly 12 segments. If the receiver counts a different number of segments between the matching UNH and this UNT, the message should be treated as invalid.
In context, a complete message envelope looks like this:
UNH+1+INVOIC:D:96A:UN'
BGM+380+INV-2024-0042+9'
DTM+137:20240315:102'
...
UNT+12+1' The reference number 1 appears in both UNH and UNT, confirming they belong to the same message.