SEGMENT
The base brick of an EDI message: a coherent group of elements carried by a tag and terminated by a delimiter.
Definition
A segment is the elementary structural unit of an EDI
message. It aggregates a coherent set of data around a single function —
party identification, amount, period, item line. In EDIFACT, its syntax is
codified by ISO 9735:
a 3-letter tag (NAD, BGM, DTM, QTY, PRI…), followed by a sequence
of data elements separated by the + character,
terminated by the apostrophe '. Composite
sub-elements are separated by the : character. All these
delimiters can be redeclared in the optional UNA service segment, useful to
transmit non-ASCII payloads safely.
An EDIFACT message is therefore an ordered sequence of segments: UNH (header), BGM (beginning), a stream of business segments (NAD, RFF, DTM, LIN, QTY, PRI…), then UNT (trailer). The UN/EDIFACT directories (D.96A, D.01B…) describe the list and the order of allowed segments per message type.
Origin
The segment concept comes straight from the standards that preceded EDIFACT, notably ANSI ASC X12 from 1979, where the same "segment + element" architecture appears. UN/EDIFACT generalised this logic with a centralised syntax and directory, formalised by ISO in 1988 (ISO 9735), revised in 2002. The term now describes a reality shared by many standards: loop / segment in X12, composite / element in EDIFACT, element / attribute in cXML and UBL.
Example in context
Three successive segments inside an ORDERS message:
Each line is a segment: NAD identifies the buyer, DTM carries the document
date (qualifier 137 = "document date", 102 = CCYYMMDD format),
QTY carries the ordered quantity (qualifier 21 = "ordered quantity"). All
three follow the same grammar: tag + composites separated by +
+ closing apostrophe.