Parse EDI Fixed-Width Transaction Records
Convert EDI (Electronic Data Interchange) fixed-width transaction records to CSV format. Covers segment identification, field extraction, and data mapping.
Legacy Formats
Detailed Explanation
EDI Fixed-Width Records
Electronic Data Interchange (EDI) is a standard for exchanging business documents between organizations. While modern EDI often uses delimited formats (like X12 with segment terminators), many legacy EDI systems use fixed-width records.
Example: Purchase Order Record
PO20240115VENDOR001 ACME Corporation 1000WIDGET-A Heavy Duty Widget 000050000250000
PO20240115VENDOR001 ACME Corporation 1001BOLT-42 Stainless Steel Bolt 001000000015015000
PO20240116VENDOR002 Global Parts Inc 1002GEAR-7X Precision Gear Assembly 000020012500250000
Field Layout
| Field | Width | Type | Description |
|---|---|---|---|
| RecordType | 2 | Alpha | "PO" for Purchase Order |
| OrderDate | 8 | Numeric | YYYYMMDD |
| VendorCode | 10 | Alphanum | Vendor identifier |
| VendorName | 25 | Alpha | Vendor name |
| LineItem | 4 | Numeric | Line item number |
| ProductCode | 10 | Alphanum | Product identifier |
| Description | 26 | Alpha | Product description |
| Quantity | 5 | Numeric | Order quantity (zero-padded) |
| UnitPrice | 6 | Numeric | Price in cents (zero-padded) |
| LineTotal | 6 | Numeric | Total in cents (zero-padded) |
CSV Output
After conversion with appropriate column definitions and trim enabled:
RecordType,OrderDate,VendorCode,VendorName,LineItem,ProductCode,Description,Quantity,UnitPrice,LineTotal
PO,20240115,VENDOR001,ACME Corporation,1000,WIDGET-A,Heavy Duty Widget,00005,000025,0000
PO,20240115,VENDOR001,ACME Corporation,1001,BOLT-42,Stainless Steel Bolt,01000,000015,015000
PO,20240116,VENDOR002,Global Parts Inc,1002,GEAR-7X,Precision Gear Assembly,00002,012500,250000
EDI-Specific Considerations
- Implied decimals: Price field
000025might mean$0.25or$25.00depending on the spec - Record type filtering: Different record types (header, detail, trailer) have different layouts
- Validation: EDI files often include check digits and running totals in trailer records
Use Case
Processing incoming EDI purchase orders, invoices, or shipping notices from trading partners who use legacy fixed-width EDI formats instead of modern X12 or EDIFACT standards.