Electronic Data Interchange
The Data Segment (UN/EDIFACT)

The data segment is the fundamental unit of information in an EDI document.  A block of information that is layered one upon another separated only by a terminator to make up the document.  Basically, the document is just composed of layers of data segments.  The data segment consists of related simple data elements in a predefined sequence; or a combination of related simple data elements and composite elements in a predefined sequence.  Each elements and their relative position in the collection describe the type of information the data segment can hold to serve a special purpose in the context of the EDI document as a whole.  Each data segment has a unique purpose and properties from other data segments.

The data segment has the following general properties:

The following properties are relevant within the context of an ASC/X12 Transaction Set, or UN/EDIFACT Message.  In these semantic entities, the data segments are organized in a predefined order, all logically related, and together with properties listed herein, define the purpose of the business transaction of the transaction set/message.

Each data segment in the document is separated by a segment terminator in the document.

Composite Elements and Data Elements

A data segment can have a combination of composite elements and simple data elements.  Or they can have composite elements only, or simple data elements only.  Each element is separated by an element separator character in the data stream.

Both simple data elements and composite elements can have repeating instances.  A repeating instance of an element occurs repeatedly at the same position in the data segment, each separated by a repeating separator character.  However, it is important to note that two elements with the same identifier can be adjacent to each other and not be deemed repeating elements.  In the data stream, they can be differentiated by the fact that:

All elements in the collection can have a mandatory (M), or optional (O,C) requirement.  Additionally, an optional element may have a relational, or dependency requirement where its required presence is dependent on the presence of other elements in the same collection.  If this relational condition exists, then a syntax rule, or dependency note, that states the relationship of the elements, is included in the data segment definition

It is possible to have all elements in the collection to have an optional requirement.  If there is no data in the elements, the data segment is not considered empty as long as its identifier stands alone in the data stream. A simple data element is considered present only if its value contain at least one character; and a composite element is considered present only if one of its component element value contain at least one character.  However, even though the identifier alone is enough to indicate its presence, the stand alone identifier is present only to satisfy the mandatory requirement of the data segment -- it should be completely ommitted if it has an optional requirement.

It is also possible to have all elements in the data segment to have a mandatory requirement.  If some elements are mandatory, these elements will normally have a position at the beginning of the collection.  If an optional data segment is present, then all mandatory elements must be present as well.  If all optional and/or mandatory elements are empty in a mandatory data segment, the data segment should be omitted completely.  However, it is an error at the mandatory element if its parent data segment is omitted (not present) and is mandatory; in this case, there are two errors: the missing data element, and the missing data segment -- both mandatory.

An empty simple data element contain no character in its value; an empty composite element contain only empty component elements.  For both structures, they are completely omitted in the data stream, including their separators that follow them if they occur at the end of their parent structure.  If the empty element is followed by a non-empty element then its absence is indicated by its separator that follow it, thus preserving the positions of non-empty values in its parent structure's data stream.