Lesson 2 of 5
ANSI X12 anatomy
9 min
Listen to this lesson
An X12 file looks like noise until you know three things: how it is delimited, how it is enveloped, and how segments are named. After that, an 850 reads like a form. Here is a real-shaped 850 from Great Lakes Fleet Services for 50 alternators. Each line is one segment; in the actual file the segments usually run together on one line.
ISA*00* *00* *ZZ*GLFLEETEDI *ZZ*CONTOSOMC *261014*0915*U*00401*000072318*1*P*>~GS*PO*GLFLEETEDI*CONTOSOMC*20261014*0915*815*X*004010~ST*850*0001~BEG*00*SA*GLF-PO-55120**20261014~DTM*002*20261021~N1*BY*GREAT LAKES FLEET SERVICES*92*GLFS~N1*ST*GREAT LAKES FLEET GRAND RAPIDS*92*GR04~PO1*1*50*EA*240.00**BP*GLF-ALT-100*VP*CMC-ALT-100~CTT*1~SE*8*0001~GE*1*815~IEA*1*000072318~
Delimiters
X12 does not use commas or tags. It uses three or four delimiter characters, and the sender declares them inside the very first segment:
- Element separator: the character right after
ISA, here*. It separates the data elements inside a segment. - Segment terminator: the character at the end of the ISA segment, here
~. It ends every segment. - Component (sub-element) separator: declared in ISA16, here
>, used inside composite elements. - Repetition separator: declared in ISA11 in version 004020 and later. In version 004010, as here, ISA11 still holds the standards identifier
U.
This is why the ISA segment is fixed length: 106 characters, with every element padded to its full size. A translator reads character 4 to learn the element separator and the last character to learn the segment terminator before it parses anything else. A partner who trims the spaces out of ISA06 breaks the whole file.
Three envelopes
Control numbers are how both sides prove completeness. The interchange number 000072318 in ISA13 must match IEA02, the group number 815 in GS06 must match GE02, and SE02 must match ST02. The trailers also count: IEA01 says one group, GE01 says one transaction set, SE01 says eight segments. A translator that finds a mismatch rejects the envelope.
Reading the 850 body
| Segment | In the sample | Meaning |
|---|---|---|
BEG | 00*SA*GLF-PO-55120**20261014 | Beginning segment: purpose 00 (original), order type SA (stand-alone), the customer's PO number and the PO date |
DTM | 002*20261021 | Date qualifier 002 = delivery requested, on 21 October 2026 |
N1 loop | BY and ST | Name segments with an entity code: BY = buying party, ST = ship-to. Qualifier 92 means the code that follows was assigned by the buyer |
PO1 | 1*50*EA*240.00**BP*GLF-ALT-100*VP*CMC-ALT-100 | Line 1: 50 each at 240.00, buyer's part number (BP) GLF-ALT-100, vendor's part number (VP) CMC-ALT-100 |
CTT | 1 | Transaction totals: one line item, a control count the receiver can check |
The business content of Great Lakes' 850.
Segments group into loops. The N1 loop, for example, can carry N2 (additional name), N3 (street) and N4 (city, state, postal code) under each N1, and the PO1 loop can carry PID (description) and further dates under each line. Each element also has a defined data type and length in the standard: ID elements take a value from a code list, AN elements are free text, DT elements are dates (CCYYMMDD in GS and the transaction set, YYMMDD in ISA), and R and N elements are decimal and implied-decimal numbers. An N2 element such as an invoice total of 1200000 means 12,000.00 because the two decimals are implied, a detail that trips up many first-time testers reading an 810.
Notice the qualifiers. X12 reuses generic segments and tells you what each instance means with a code: DTM*002 is a requested delivery date, while DTM*010 would be a requested ship date. N1*ST is a ship-to, N1*BT a bill-to. Most mapping mistakes are qualifier mistakes, so a good implementation guide lists the exact qualifiers a partner sends.
Versions and implementation guides
X12 publishes a new release every year (version numbers like 004010, 005010 or 008050) and organizes its catalog by subcommittee: the 850, 855, 856 and 830 belong to X12M Supply Chain, the 810 to X12F Finance, and the 997 and 999 to X12C Communications and Controls. Partners do not move versions every year. Many supply-chain relationships still run on 004010, which is what Great Lakes uses. The version appears in ISA12 (00401) and GS08 (004010).
The standard only defines what is allowed. Each partner publishes an implementation guide (often called a mapping spec or companion guide) that says which segments it actually sends, which qualifiers, which are mandatory for them and what the values mean. Great Lakes' guide, for example, says it always sends its own ship-to location code in N1*ST with qualifier 92 and its own part number with qualifier BP. That guide, not the standard, is what Contoso's mapping must satisfy.
What would you do?
Great Lakes sends a test 850 in which PO1 has <code>BP*GLF-ALT-100</code> but no <code>VP</code> element. Contoso's first draft map expected the vendor part number. What should Theo do?
- X12 uses an element separator, a segment terminator and a component separator, all declared in the fixed-length ISA segment.
- Three envelopes nest: ISA/IEA interchange, GS/GE functional group, ST/SE transaction set; each trailer repeats the control number and a count.
- Qualifiers such as DTM*002 or N1*ST give generic segments their meaning; most mapping errors are qualifier errors.
- The partner's implementation guide, not the bare standard, defines what Contoso must handle.
Check your understanding · not graded
Lesson check
1. In an ANSI X12 file, which segment opens the interchange envelope?
2. Why must the ISA segment keep its fixed length of 106 characters?
3. In Great Lakes' 850, what does <code>N1*ST</code> identify?
4. What does SE01 in an X12 transaction set contain?