Purpose
The UNZ (Interchange Trailer) segment is the very last segment in any UN/EDIFACT interchange. It closes the interchange envelope that was opened by the UNB segment and provides two essential pieces of information for integrity checking: the number of messages contained in the interchange and the interchange control reference. These values allow the receiving system to confirm that all messages arrived intact and that the interchange was not truncated during transmission.
The UNZ segment is always paired with the opening UNB segment. Together, they form the outermost layer of the EDIFACT envelope structure. Inside this envelope, individual messages are wrapped in their own UNH/UNT pairs.
Data Elements
The UNZ segment contains just two mandatory data elements:
- 0036 - Interchange Control Count: The total number of messages contained in the interchange. This includes every UNH/UNT pair within the envelope. If the interchange contains three invoices, this value would be 3.
- 0020 - Interchange Control Reference: Must be identical to the interchange control reference specified in the corresponding UNB segment. This reference pairs the header and trailer together and allows the receiver to match them unambiguously.
Format and Syntax
The format of a UNZ segment is concise:
UNZ+messageCount+interchangeControlReference' The plus sign (+) separates data elements, and the segment ends with the standard segment terminator (typically an apostrophe).
Messages That Use UNZ
The UNZ segment is not specific to any message type. It appears in every EDIFACT interchange, regardless of the type or number of messages contained within. An interchange may hold a single ORDERS message, a batch of fifty INVOIC messages, or a mix of different message types. In all cases, UNZ closes the interchange.
Example
A UNZ segment closing an interchange that contained a single message:
UNZ+1+IC20240315001' This tells the receiver that the interchange with control reference IC20240315001 should contain exactly 1 message. The control reference must match the one in the corresponding UNB segment.
A complete interchange envelope in context:
UNB+UNOC:3+5412345678908:14+8798765432106:14+240315:1430+IC20240315001'
UNH+1+INVOIC:D:96A:UN'
...
UNT+12+1'
UNZ+1+IC20240315001' The reference IC20240315001 links the UNB and UNZ together, and the count of 1 confirms one message was transmitted. If you were to add a second message (a new UNH/UNT pair), the count in UNZ would change to 2.