997 AK9 code 4 or 5: the functional group trailer is wrong
The group envelope (GS ... GE) around your transaction sets has a trailer that doesn't match its header, or claims the wrong number of transaction sets. The partner can reject the entire batch, not just one 214.
What you see
AK1*QM*417~
AK9*R*1*1*0*4~
or, when the count is wrong:
AK1*QM*417~
AK9*R*1*2*0*5~
Reading AK9: AK901 = group status (A, E, P partially accepted, R), AK902 = number of sets the GE says are included, AK903 = number actually received, AK904 = number accepted, AK905+ = error codes. Exact counts can vary by translator.
What it means
- Element 716 code 4 = Group Control Number in the Functional Group Header and Trailer Do Not Agree:
GS06≠GE02. - Code 5 = Number of Included Transaction Sets Does Not Match Actual Count:
GE01≠ the number of ST/SE pairs in the group.
Why it happens
- GE02 is written from a counter that was already incremented.
- GE01 is hard-coded to 1, but the batch job put several 214s in the group.
- A 214 was removed from or added to a batch by hand.
The exact fix
- Set
GE02equal toGS06. - Set
GE01to the number ofSTsegments between that GS and GE. - Resend with a new ISA13 (and a new GS06 if your partner tracks duplicates at the group level).
Before and after
GS*QM*XMPL*BROKERX*20261021*1430*417*X*004010~ ST*214*0001~ ... SE*9*0001~ ST*214*0002~ ... SE*6*0002~ GE*1*418~
GS*QM*XMPL*BROKERX*20261021*1430*417*X*004010~ ST*214*0001~ ... SE*9*0001~ ST*214*0002~ ... SE*6*0002~ GE*2*417~
"..." stands for the segments inside each transaction set, shortened for space.
Also check GS01 and GS08
GS01 must match the transaction sets inside the group: QM for 214, IM for 210, SM for 204, GF for 990, and FA for 997. GS08 must be the version your partner expects (for example 004010). A version they don't support comes back as AK9 code 2 (Functional Group Version Not Supported).
Not sure this is your error?
Paste your 997, TA1, rejected file, or the broker's error email into the free EDI Reject Checker. It decodes every AK3/AK4/AK5/AK9 and TA1 code and checks counts, control numbers, and dates in seconds. It runs in your browser, so nothing is uploaded.
Fix reports are paid up front; if we can't find the cause, the refund is automatic.
References
- Element 716, Functional Group Syntax Error Code (codes 2, 4, 5)
- GS Functional Group Header, 004010
- Element 479, Functional Identifier Code (QM, IM, SM, GF, FA)
- X12, Transaction Sets