The EDI segment that can feed a logistics agent the wrong times
Before connecting a TMS to an agent, learn the five X12 messages you will meet most often and why G62 changes meaning between them.
In brief
- In a 214, the status time sits in AT7. G62 must not be used to report it, while G62 in the header of a 204 is the deadline for responding.
- A 997 says only that a message passed technical checks. To learn whether a tender was accepted or rejected, look at the 990.
- Never generate a 997 in reply to a 997. Tests must include a rejected tender that returns to dispatch.
Five X12 message types carry most of what an agent needs to answer a logistics client’s question: “Where is this shipment, and is it late?” Take a Forward Deployed Engineer in the first week at a logistics company that wants exactly such an agent.
The IT team opens up a folder full of text files. Each line starts with two or three capital letters, and its fields are separated by symbols. The client’s TMS has no REST API, only EDI X12.
The model is the easy part here. The difficulty is reading the messages correctly, because the same segment means different things depending on the message that contains it. If the parser gets it wrong, the agent still answers with full confidence, and the answer is wrong.
This guide covers the five message types you will meet most often, one specific parser trap, and the test cases the client will use to judge you.
Which messages does a shipment generate?
For full-truckload road freight, everything starts with the 204. A shipper or another interested party uses it to tender a load to a full-truckload carrier. Inside are B2 with basic shipment data, S5 for each stop, N1 for the parties involved and L11 for reference numbers.
The carrier replies with a 990, accepting or rejecting the load. Once the truck is moving, it sends 214s to report shipment status to the shipper, consignee and agents. The opening segment, B10, carries identifiers such as the shipment reference number. AT7 is the core: it holds the status code, the reason, the time of the status and appointment information.
Ocean freight uses the 315 to report shipment events. You will read N9 for references, Q2 for the vessel and shipping dates, R4 for ports and SG for status.
The 997 is the functional acknowledgment, sent in reply to a message or group of messages. With it, the receiver reports that it has received the message, and that the message was accepted, accepted with errors or rejected.
| Message | Who sends it, and why | Segments to read first | What the AI system uses it for |
|---|---|---|---|
| 204 | Shipper tenders a load to a carrier | B2, S5, N1, L11, G62 (response deadline) | The plan: stops, parties, deadline for replying |
| 990 | Carrier accepts or rejects | Tied to the right version of the 204 | Knowing whether the load has a truck or must be reassigned |
| 214 | Carrier reports road status | B10, AT7 | The event timeline for predicting delays |
| 315 | Reports ocean events | N9, Q2, R4, SG | Vessel, ports, shipment status |
| 997 | Receiver acknowledges on a technical level | AK5, AK9 | Health of the connection, not business status |
The G62 trap: a segment that changes meaning by message
TrueCommerce’s 214 guide contains a short rule: G62 must not be used to report the date and time of a shipment status. That time belongs in AT7. In a 204, meanwhile, G62 in the header carries the deadline for responding to the tender.
Say a hurried engineer writes one “find the date and time” function that serves every message by scanning for G62. On a 204, it picks up the response deadline and records it as a shipment event.
On a 214, it skips AT7, where the real time is. The agent will then rely on timestamps that are not events to announce that “the shipment is 6 hours late.”
The parser therefore has to route by message type first and read segments second. The Python sketch below deliberately omits the position of each field. Field positions come from each partner’s implementation guide, never from guesswork.
def parse_segments(raw, seg_term="~", elem_sep="*"):
# set delimiters from the partner's documentation; don't assume defaults
return [s.strip().split(elem_sep) for s in raw.split(seg_term) if s.strip()]
def first(segs, tag):
return next((s for s in segs if s[0] == tag), None)
# tx_type: read from the first element after the ST segment name, e.g. first(segs, "ST")[1] == "214"
# field_map: lookup table you build from the implementation guide; pick(seg, name) returns the element at the recorded position
def to_records(tx_type, segs, field_map):
if tx_type == "214":
return {
"shipment_ref": field_map.pick(first(segs, "B10"), "shipment_ref"),
# event times come ONLY from AT7, not from G62
"events": [field_map.pick(s, "status") for s in segs if s[0] == "AT7"],
}
if tx_type == "204":
return {
"stops": [s for s in segs if s[0] == "S5"],
# G62 in the 204 header = deadline for responding to the tender
"respond_by": field_map.pick(first(segs, "G62"), "datetime"),
}
if tx_type == "997":
return {"ack": True} # record only, do not reply
raise ValueError(f"{tx_type} is not supported yet")
This structure forces you to answer “what is this message?” before “what is this field?” When the client adds 315s for ocean freight, you add one branch that reads N9, Q2, R4 and SG, and leave the 214 logic alone.
A 997 says “received,” not “agreed”
The second error usually shows up later, after the system has been running for a few weeks. In a 997, AK5 reports the result for each transaction set along with any errors, while AK9 reports the result for the whole functional group and the number of transaction sets. Seeing nothing but accepted statuses, people easily conclude that every load is fine.
A 997 or 999 says only that a message passed technical checks. A 204 can receive an accepting 997 and then a rejecting 990. The business outcome has to be tracked separately, through the 990 or a reconciliation report.
A 990 is also tied to a particular version of the 204. If the client revises a tender twice, the system must match the acceptance to the right version. A rejected tender must go back to dispatch for reassignment; it cannot be left sitting in a “sent” state.
The reverse direction needs a hard rule too. The X12 standard says a 997 must not itself be acknowledged, to avoid an endless loop of acknowledgments. If your AI pipeline generates messages, write a test proving that it never answers a 997 with a 997.
Four steps to connecting a client’s EDI
The first thing to request on site is each partner’s implementation guide; database access is not the place to start. Build a lookup table of message type, segment, field and business meaning. Take it to a dispatcher and spend a session going through it, because dispatchers know which status codes are actually used.
Second, build a parser that routes by message type, as above, and store the original message next to the normalized record. When the agent gives a wrong answer, you need to trace it back to the exact AT7 or SG line that produced it.
Third, keep two separate status tables: one for 997s (is the connection healthy?) and one for 204/990/214 (what is happening to the load?). The AI system reads only the second. The first is for operational alerts.
The final step is the test suite. Stacksync’s 990 testing guide calls for testing a rejected tender and confirming that it returns to dispatch for reassignment. Write this test case first: if it fails, a rejected load will sit idle with nobody assigning another truck.
The errors that cost you the client’s trust
The common errors are familiar: taking event times from G62 in a 214, treating an accepting 997 as an accepted tender, matching a 990 to an old 204, forgetting the rejection case, and letting the pipeline answer a 997 with a 997. None of them takes AI expertise to fix. All of them take careful reading of the documentation and early tests.
On the career side, look for “EDI,” “X12” and “TMS” in FDE and solutions engineer postings in logistics. If they appear, ask directly in the interview how much of the role’s time goes to integration.
On your résumé, “EDI experience” is too thin. State specifically that you connected 204/990/214 flows, reconciled 997s separately from business outcomes, and had a test suite for rejected tenders.
A delay-prediction agent is only as good as the timeline it receives. For a logistics client, that starts with taking event times from AT7 rather than G62.
Was this article useful?
Thanks for the feedback!
7 sources
- Product: X12 EDI (TrueCommerce: X12 214 Transportation Carrier Shipment Status Message)
- EDI 214 Transportation Carrier Shipment Status Message (Stedi X12 004010)
- EDI 204 Motor Carrier Load Tender (Stedi X12 004050)
- EDI 990 Response to a Load Tender (Stedi X12 004050)
- Stacksync: XPO Logistics Freight Inc, EDI 990
- EDI 997 Functional Acknowledgment (Stedi X12 004010)
- EDI 315 Status Details (Ocean) (Stedi X12 003060)