EDI Segments
Why are segments Important?
The segment is what makes an EDI file an EDI file. They are at the very heart of EDI. There are hundreds of different types of segments and each holds a different type of data.
N1^BT^Bill Gates^01^123456789~
For instance the ‘N1′ segments holds some common data that is used in many EDI documents. First, the ‘N1′ type. This is the name type. The first elements following is the qualifier for the second field. If this is were an invoice it might be the code ‘BT’ indicating that the value in the second field is the name of the “Bill To’ party, in this case ‘Bill Gates’. Following the name is another qualifier that determines the type of the account number in the fourth filed. In this case we will use the DUNS Number, and so on. We stop now with the segment terminator to indicate to the parser that the next character will start a new segment.
What are Segments?
In EDI a segment occupies the space from the character directly following a segment delimiter, to and including the next segment delimiter.
How are segments used?
By using segments, EDI files are able to represent data in a compact, logical arraignment. Parsing out the data is just a function of recognizing the pertinent segments and reading the data. As a rule of thumb, segments should only be as long as the data they contain. So even if there are 10 possible elements in the segment, if we only have data in 4, we terminate the segment there. We discuss that further in the Good Form section. This PO1 segment illustrates the salient points.
PO1^1^100^EA^100.00^^VN^A-1234~
The PO1 line in the specification for 4010 can have 25 elements, but we only have the basic required elements and one set of the identifiers. This only takes us to the 7th element. The remaining 18 elements are not needed, and so are not included.
Also of note is the PO1_5. This element is optional, so there is no data there. But because we are using elements after it, it must be present, even if empty, to keep the position of the elements that come after it.
Summary
Segments in EDI don’t just occur randomly. There are some segments, those involved in enveloping, that have a mandated location across all EDI files. Each type of EDI document has a logical order that segments are to follow. A shipping notice will have an defined set of segments and order of segments. Some will be required, and some will be optional, and some will be conditional on other segments. An invoice on the other hand will have a different defined set of segments, some will be in common, and some will be unique to those of the shipping notice. We will see this illustrated in the mapping exercised that use EDI formats.
Looking for something else relating to EDI? Check out the EDI Primer post
Subscribe to "The Integration Engineer" by Email
Find out about the tools and services available at The Integration Engineer's Consulting site.











