Now opening: online payments go live shortly. Email support@otrsi.ai and we'll take your request first.
Over The Road SIOTRSI

997 AK5*R*4: segment count in SE01 doesn't match

The partner's translator counted the segments in your transaction set and got a different number than the one you put in the SE trailer. The whole transaction set is rejected, even if every other segment is perfect.

What you see

AK1*QM*417~
AK2*214*0001~
AK5*R*4~
AK9*R*1*1*0~

In a portal or reject email, this usually reads as "number of included segments does not match actual count," "SE01 count error," or "segment count mismatch."

What it means

AK502 code 4 (element 718) = Number of Included Segments Does Not Match Actual Count. SE01 (element 96) must be the total number of segments in the transaction set including the ST and SE segments themselves. ISA, GS, GE, and IEA are not counted.

Why it happens

The exact fix

  1. Count every segment from ST through SE, including both. With ~ as the segment terminator, that's the number of ~ from ST to SE.
  2. Put that number in SE01. Leave SE02 (the control number) alone; it must still match ST02.
  3. Resend with a new ISA13 interchange control number (and a new GS06 if your partner requires it) so it isn't flagged as a duplicate.
  4. Fix the map so the count is calculated last, after all segments are written.

Before and after

Rejected (SE01 = 8)
ST*214*0001~
B10*PRO88231*5523901*XMPL~
L11*5523901*CR~
N1*SH*ACME PAPER MILL~
LX*1~
AT7*X1*NS***20261021*1430*CT~
MS1*MEMPHIS*TN*US~
MS2*XMPL*1042~
SE*8*0001~
Accepted (9 segments, ST to SE)
ST*214*0001~
B10*PRO88231*5523901*XMPL~
L11*5523901*CR~
N1*SH*ACME PAPER MILL~
LX*1~
AT7*X1*NS***20261021*1430*CT~
MS1*MEMPHIS*TN*US~
MS2*XMPL*1042~
SE*9*0001~

Stop it happening again

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