Common EDI errors explained, and how to fix them
Most rejected EDIFACT and X12 files fail on a handful of envelope rules: a count, a control number, a separator. Here is each one with a wrong and a right example, and what to read in the 997 or CONTRL that comes back.
1. The segment count in UNT or SE is wrong
UNT (EDIFACT) and SE (X12) must count every segment of the message, header and trailer included. A segment added or removed by hand, or a mapping that skips one, breaks the count.
UNH+1+ORDERS:D:96A:UN:EAN008' … 21 segments … UNT+22+1' ← wrong: the message has 23 segments UNT+23+1' ← right
EDI Reader Pro reports it on the trailer: “Message trailer declares 22 segment(s), 23 counted.” In a 997, the same error is AK5 code 4: number of included segments does not match actual count.
2. The control numbers do not match
Each trailer repeats the control number of its header: UNB/UNZ and UNH/UNT in EDIFACT; ISA13/IEA02, GS06/GE02 and ST02/SE02 in X12. It breaks when files are merged, split or renumbered by a script.
ISA*…*000000905*0*P*>~ … IEA*1*000000904~ ← wrong IEA*1*000000905~ ← right
EDI Reader Pro: “Interchange reference differs: header 000000905, trailer 000000904.” The same check runs for groups and messages. In a 997, a set-level mismatch is AK5 code 3: transaction set control number in header and trailer do not match.
3. The trailer announces the wrong number of messages or groups
UNZ counts the messages of the interchange (or the groups, when UNG is used), GE01 counts the transaction sets of a group, and IEA01 counts the functional groups. Removing one message from a batch without updating the trailer is the classic cause.
EDI Reader Pro compares each count with what the file contains, for example: “Group trailer declares 2 message(s), 1 found.”
4. CTT does not match the line items
In an X12 850, 810 or 856, CTT01 gives the number of line items: PO1, IT1 or HL segments. A partner who counts them and finds another number rejects the set.
PO1*1*120*EA*4.75**BP*ART-1001~ PO1*2*48*EA*12.30**BP*ART-1002~ CTT*3~ ← wrong: two PO1 lines CTT*2~ ← right
EDI Reader Pro: “CTT declares 3 line(s), 2 PO1 segment(s) found.”
5. ISA is not 106 characters
ISA is the only fixed-width segment: 16 elements, 106 characters, and the separators are read from positions 4, 105 and 106. One space missing in the padded sender ID moves the component separator and the segment terminator.
ISA*00* *00* *ZZ*NOVAIRSENDER *ZZ*ACMEBUYER *… ← 14 characters: wrong ISA*00* *00* *ZZ*NOVAIRSENDER *ZZ*ACMEBUYER *… ← 15 characters: right
EDI Reader reads the separators from these positions, like a translator does, so the mistake shows at once: a single-line file falls apart into a few unknown segments and the check reports missing GS, GE or IEA segments. There is no dedicated “ISA length” message in this version: when that happens, count the ISA first.
6. Empty or unknown qualifiers
A NAD or N1 without its party qualifier (NAD++… or N1**…) cannot be routed: the partner does not know if it is the buyer, the supplier or the delivery point. EDI Reader Pro: “Segment NAD: qualifier at element 1 is empty.”
A qualifier that is present but unknown to the partner (a code their implementation guide does not list) is a different error, reported in a 997 as AK4 code 7, invalid code value. EDI Reader shows such a code as is, without a label, and does not flag it: only the partner's guide says which codes they accept.
7. A mandatory segment is missing
Each message type has segments it cannot do without: BGM and DTM in an ORDERS, BEG and PO1 in an 850, BIG and TDS in an 810. EDI Reader Pro checks them for ORDERS, DESADV, INVOIC, 850, 810 and 856: “Mandatory segment BGM is missing.” In a 997 it is AK3 code 3, mandatory segment missing.
8. Reading a 997 or a CONTRL rejection
When a partner rejects a file, the answer is usually a 997 functional acknowledgment (X12) or a CONTRL syntax and service report (EDIFACT). The verdict is in a few segments:
ST*997*0001~ AK1*PO*905~ group acknowledged: PO, control number 905 AK2*850*0001~ transaction set 850, control number 0001 AK5*R*4~ R = rejected, 4 = segment count does not match AK9*R*1*1*0~ group rejected: 1 set included, 1 received, 0 accepted SE*6*0001~
- AK5 and AK9: A accepted, E accepted with errors, R rejected (AK9 also has P, partially accepted).
- AK3: the segment in error, its position in the set and a code (for example 3, mandatory segment missing; 8, segment has data element errors).
- AK4: the element in error and a code (for example 1, mandatory data element missing; 7, invalid code value; 8, invalid date).
- CONTRL: UCI answers for the interchange, UCM for each message; action code 4 means rejected, 7 acknowledged, and the syntax error code says why (for example 28, references do not match; 29, control count does not match).
EDI Reader opens 997 and CONTRL files and names the message type. In this version the acknowledgment segments themselves (AK1 to AK9, UCI, UCM) are not in the built-in dictionary: they are shown raw with their element positions, never hidden. Read the verdict there, then open the original file to find the segment it points to.
EDIFACT DESADV explained: SSCC, GLN and why retailers reject a despatch advice
Frequently asked questions
What is the most common EDI error?
Envelope counts and control numbers: a UNT or SE segment count that is off by one, or a trailer that repeats another control number than its header. Both are easy to fix and easy to miss by eye.
What does AK5*R mean in a 997?
The transaction set was rejected. The second element gives the reason, for example 4 when the number of included segments does not match the actual count; AK3 and AK4 segments before it point to the segment and element in error.
Can I check a file before sending it to my partner?
Yes. EDI Reader for VS Code runs the check on your machine and tells you how many problems a file has; EDI Reader Pro shows each one on its segment, checks whole folders and saves an HTML report. Your partner's implementation guide can add rules that no generic tool knows.
Is the online viewer able to find these errors?
The free online EDI viewer decodes the file in your browser and runs the same check, without uploading anything. It tells you when problems are found; EDI Reader Pro in VS Code shows where they are.
Read your own files the same way
EDI Reader for VS Code names every segment and code of your EDIFACT and X12 files, on your machine. Free, no account; Pro adds the check, CSV and JSON export and folder checks.
A format or an in-house rule of your own? We build it in five working days, at a fixed price: EUR 490 + VAT where applicable, per work package. See the work packages