Costco Edi 997

By Alexander Georges|Updated July 28, 2026
TL;DR: This guide explains how to read, validate, and remediate Costco EDI 997 functional acknowledgment files (effective 2026-05-31). It includes annotated EDI 997 code, CSV conversion examples, step-by-step validation and conversion instructions, common error codes with fixes, and best practices using PlainEDI to prevent and resolve rejections. Verify current requirements with the retailer portal.

What This Is

This guide focuses on Costco EDI 997 files — the X12 functional acknowledgment used by Costco to confirm receipt and syntactic validation of inbound EDI transactions (POs, invoices, ASNs). The EDI 997 does not contain business data like quantities; instead it reports whether documents were accepted or rejected with segment-level detail. You will learn how to parse a 997, translate it to CSV for audit and downstream systems, understand AK1/AK2/AK3/AK4/AK5/AK9 meanings, and remediate the original errors so your trading partner documents pass Costco's validation rules.

Costco-specific vendor expectations and enforcement rules were last updated on 2026-05-31. Because that date is more than 30 days old, verify current requirements with the Costco vendor portal before taking action. This guide teaches universal technical steps and operational best practices you will apply even when Costco updates their compliance rules.

Who This Is For

This guide is aimed at EDI analysts, integration engineers, vendor compliance teams, and third-party logistics providers who receive or generate Costco EDI 997 acknowledgments and need to convert, validate, and act on them in automated pipelines or manual workflows.

Key Segments Explained

The EDI 997 is small but precise. Understanding each segment lets you pinpoint whether a problem is syntax-level, structural, or business-rule-related. The following segments are critical to Costco 997 processing.

  • ISA (Interchange Control Header)

    The ISA defines interchange-level delimiters, sender/receiver IDs, and control numbers. Important elements: ISA13 (Interchange Control Number) and ISA11 (repetition separator for 997 when used). Costco systems require exact partner IDs and matching control numbers across ISA/IEA. If delimiters are wrong, parsers will fail before you reach AK segments.

  • GS (Functional Group Header)

    GS02 is the application sender code, GS03 is application receiver. The GS/GE control numbers must match. Costco often groups multiple transactions; AK1/AK9 block-level acknowledgments reference the GS.

  • ST / SE (Transaction Set Header and Trailer)

    ST01 identifies the transaction set type (997). SE01 counts included segments. If SE segment counts do not match the parser's count, Costco's system will generate an AK5 with rejection details.

  • AK1 / AK2 / AK3 / AK4 / AK5

    These are the meat of the 997:

    • AK1 — Identifies the functional group being acknowledged (GS functional ID, GS control number).
    • AK2 — Identifies the transaction set acknowledged (e.g., ST02 references the original ST control number and ST01 the transaction type like 850/856/810).
    • AK3 — Points to the specific segment in the original document that caused a syntax error (segment ID and loop reference). Costco uses AK3 to direct you to the offending segment position.
    • AK4 — Points to the exact element or sub-element error within a segment (element position and expected data type or value). AK4 codes include syntax and data errors.
    • AK5 — Indicates transaction acceptance/rejection with a status code (A = accepted, R = rejected, E = accepted with errors but functional, see implementation convention for exact codes).
  • AK9 (Functional Group Response)

    AK9 summarizes the status of the entire functional group and provides counts: transaction sets accepted/rejected. AK9 is essential when multiple STs are included; it lets you prioritize which ST to fix first.

Example EDI Snippet

ISA*00*          *00*          *ZZ*SENDERID      *ZZ*COSTCOID      *210701*1700*^*00501*000000905*1*T*:~
GS*FA*SENDERID*COSTCOID*20210701*1700*905*X*005010~
ST*997*0001~
AK1*PO*12345~
AK2*850*0000123~
AK3*N1*2*5~
AK4*01*R*88*Invalid Name Format~
AK5*R~
AK9*R*1*1*0~
SE*9*0001~
GE*1*905~
IEA*1*000000905~

Line-by-line explanation:

  • ISA*...~ — Interchange header. ISA13=000000905 is the interchange control number. Delimiter is * and segment terminator is ~. The caret ^ in ISA indicates component element separator.
  • GS*FA*...~ — Functional group for acknowledgments (FA). GS06=905 is group control number matching GE.
  • ST*997*0001~ — ST indicates this is a 997 with control number 0001.
  • AK1*PO*12345~ — Acknowledging a functional group with ID "PO" and GS control 12345 (example).
  • AK2*850*0000123~ — ACK references the original transaction set: 850 Purchase Order with ST control 0000123.
  • AK3*N1*2*5~ — The parser found an error in the third segment type: N1; error occurred at segment position 2 with loop id 5. This helps you open the original 850 at the right place.
  • AK4*01*R*88*Invalid Name Format~ — Element-level detail: element position 01 had a rejection code 'R' with an implementation-specific description "Invalid Name Format".
  • AK5*R~ — Transaction rejected at the transaction set level.
  • AK9*R*1*1*0~ — Functional group rejected: 1 transaction set in group, 1 accepted? (implementation-specific counts) and 0 rejected — interpret against X12 spec and Costco implementation note.
  • SE*9*0001~ — Transaction set trailer: 9 segments counted, ST control 0001. If the segment count is wrong, Costco's system will generate a rejection.
  • GE/IEA — Standard group and interchange trailers with matching control numbers.

CSV Output Example

Converting a 997 to CSV is useful for dashboards and integration with reporting tools. The table below demonstrates a common mapping converted from the example 997 above.

CSV Column Mapped Value Notes
interchange_control_number 000000905 From ISA13
functional_group_control 905 From GS06
transaction_set_control 0001 From ST02
original_transaction_type 850 From AK2-01
original_transaction_control 0000123 From AK2-02
segment_in_error N1 From AK3-01
element_position_in_error 01 From AK4-01
error_code R From AK4-02
error_description Invalid Name Format From AK4-04
transaction_status R From AK5

Step-by-Step Conversion Process

  1. Initial Interchange Validation
    • Confirm ISA delimiters (element separator, component separator, segment terminator). Mis-specified delimiters will break parsing. Use a simple regex or an EDI parser's setting to detect delimiters from ISA.
    • Verify ISA13 matches the IEA control number. If mismatch exists, flag as interchange-level error and stop processing the interchange.
  2. Group and Transaction Header Checks
    • Verify GS06 equals GE02. Verify ST02 equals SE02. If counts mismatch, log an AK5-type fault and route to manual review.
    • Extract AK1 to determine which functional group and GS control this 997 references.
  3. Detailed AK Parsing
    • For each AK2, map the original transaction (AK2-01 transaction ID and AK2-02 control). This gives you the target transaction to fetch from your archive or message queue.
    • If AK3 exists, parse segment ID, position, and loop context. Use this to open the upstream file and locate the exact segment.
    • Parse AK4 to identify the element or sub-element error. Capture error code and textual description for reporting.
  4. Create CSV Row(s)
    • Map fields from the 997 into a CSV schema (see example CSV table). Include context fields: timestamps, partner IDs, control numbers, and original file name for auditability.
    • Use consistent column names so your downstream ETL and ticketing systems can ingest the rows automatically.
  5. Remediation Workflow
    • Open the original document referenced by AK2. Locate the segment and element positions indicated by AK3/AK4.
    • Apply fix: element format correction, missing element insertion, delimiter escape, or business-value correction per Costco's implementation guide. Re-run validation locally before resend.
    • Create a ticket with the CSV row attached and the original EDI snippet. Include a note referencing the 997 control numbers (ISA13, GS06, ST02).
  6. Resend and Verify
    • After correction, resend the corrected transaction to Costco via your VAN or AS2 channel. Track the new 997 to verify acceptance.
    • Automate this flow with a tool like PlainEDI to validate and convert EDI to CSV pre-send and to ingest incoming 997s for instant triage.

Common Errors and Fixes

  • Error: Separator mismatch / parse failure — Symptom: Parser errors at start of file, no AK segments parsed. Fix: Confirm ISA element separator (ISA* has position 4), segment terminator (usually ~). Re-encode file with correct separators and resend. Use PlainEDI's automatic delimiter detection to prevent this error.
  • Error: ISA/IEA control number mismatch (Interchange control mismatch) — Symptom: Costco rejects interchange or produces a group-level failure. Fix: Ensure your EDI stack increments and writes ISA13 correctly and that IEA01 matches. Audit your batching process to ensure control numbers are unique per interchange.
  • Error: SE segment count incorrect (AK5/AK9 with count mismatch) — Symptom: AK5=R, AK3 pointing to SE. Fix: Recalculate segment count during generation. Many libraries count all segments including ST/SE; verify whether your generator includes nested segments and update SE01 accordingly.
  • Error: AK4 element syntax error (Invalid data format) — Symptom: AK4 with position and code; text indicates type mismatch (e.g., numeric expected). Fix: Validate each element against X12 data type rules (Nn for numeric, ID values per code list) before sending. Update mapping rules to coerce or reject invalid values prior to transmission.
  • Error: Missing required segment (AK3 points to segment missing) — Symptom: AK3 references a segment that your file lacks (loop misalignment). Fix: Review mapping and loops per Costco's EDI implementation guideline. Ensure optional/required segments are present as required. Test corrected file with validation tools.
  • Error: Functional group ID mismatch (AK1 indicates wrong GS functional ID) — Symptom: Costco expected FA but received a different functional ID. Fix: Ensure your envelope uses the correct functional group IDs per message type and Costco implementation notes.
  • Error: AK5 = E (Accepted with errors) — Symptom: Transaction accepted but with data-issue warnings. Fix: Extract AK3/AK4 details, correct source data, and monitor downstream reconciliation to prevent chargebacks or operational disputes.

Related Resources

Practical Case Studies

Case Study 1 — Missing N1 Element Causing Rejection: A vendor transmitted an 850 PO where the N1 loop had a missing N103 (Name) element. Costco returned a 997 with AK3*N1*2*5 and AK4*03*R*88*Missing N103. Remediation: the vendor updated the mapping to populate N103 from the ERP's customer name field and used PlainEDI to pre-validate the 850 before resend. The corrected PO was accepted and a confirming 997 with AK5=A was received the next day.

Case Study 2 — Separator Corruption on FTP: An automated SFTP transfer improperly converted LF to CRLF and replaced the segment terminator, causing parser failures. The vendor's monitor detected repeated 997 blank responses. Fix: Reconfigure SFTP binary mode and add a pre-flight validation that checks ISA delimiter bytes. After enabling these checks and using PlainEDI's delimiter detection, the vendor eliminated the parsing failures.

Best Practices and Operational Tips

  • Archive original inbound and outbound EDI files using the interchange and transaction control numbers for audit and dispute resolution.
  • Automate extraction of AK2/AK3/AK4 rows to generate tickets with context (original file, segment snippet, and suggested fix).
  • Use schema-based EDI validation prior to sending. PlainEDI provides both syntax and Costco-specific rule validation when you upload files to PlainEDI.
  • Monitor 997s every business day. Rejections should be treated as operational incidents and resolved within your SLA to avoid retailer deductions and delays.
  • Keep a test trading partner environment and exchange files there to validate changes before production.

FAQ Section

Q: What does AK5*R mean on a Costco 997?

AK5*R indicates the referenced transaction set was rejected at the transaction set level. The 997 will include AK3/AK4 segments that pinpoint the segment and element in error. Use those pointers to locate and fix the specific syntax or data issue in the original transaction.

Q: How do I find the original document referenced by an AK2?

AK2 contains the original transaction set ID and control number (e.g., 850 and ST control 0000123). Search your outbound archives for ST with ST02 matching the control number and the ST01 matching the transaction type. Ensure your archival index includes ISA/GS/ST control numbers for this lookup to be deterministic.

Q: Why did my parser fail before reading AK segments?

Parser failures before AK segments are usually due to delimiter mismatches (element separator, component separator, or segment terminator). Confirm the ISA positions for delimiters and use binary-safe transfers (SFTP in binary mode). Validate the file's byte-level structure using a hex viewer if necessary.

Q: Can I convert a 997 to CSV automatically?

Yes. Map interchange and AK segment fields to a CSV schema like the example table in this guide. Automate conversion using an EDI parser or a tool like PlainEDI which outputs CSVs ready for import into BI and ticketing systems.

Q: What penalties does Costco impose for EDI non-compliance?

Retailers, including Costco, enforce penalties for EDI compliance failures. Types of penalties include chargebacks for ASN accuracy, OTIF enforcement, and deductions for invoice mismatches. Effective date for the last update used in this guide is 2026-05-31. Verify current penalty amounts and thresholds with the Costco vendor portal.

Q: How should I prioritize fixes when a 997 includes multiple AK2 entries?

Prioritize based on business impact: transactions linked to shipments and invoices are higher priority than low-impact notifications. Use AK9 counts and AK5 statuses to determine which transactions are rejected vs. accepted-with-errors, then fix rejections first. Automate triage so that high-volume rejections create immediate alerts.

Q: What is the difference between AK3 and AK4?

AK3 points to the segment level location of an error in the original transaction (segment ID and position). AK4 pinpoints the element or sub-element within that segment. Use both together to find the exact character or value needing correction.

Q: How do I prevent SE segment count mismatches?

Ensure your EDI generator counts segments exactly as output, including any conditional segments. Use a proven EDI library that automatically computes SE01. Include a pre-send validation step to compare the SE count to the actual segment count byte-for-byte. Tools like PlainEDI perform this check automatically.

Final Notes and Call to Action

Costco EDI 997s are your fastest feedback loop for fixing syntactic and structural issues. Implement the step-by-step validation, CSV conversion, and remediation actions described above to lower rejection rates and improve compliance. Because the Costco update cited here is effective 2026-05-31, verify current requirements with the Costco vendor portal.

To automate validation, conversion, and triage of incoming 997s, upload a sample file now to PlainEDI for instant delimiter detection, compliance validation, and CSV extraction. PlainEDI's validation prevents common errors and speeds up remediation by producing actionable CSV records for each AK entry.