Read an EDI interchange file¶
EdiManager.File().Path(p).Read() is the sanctioned entry point for reading an ASC X12 interchange file. It loads the physical file, delegates lexical parsing to EdiSegmentParser (Parse EDI text into segments and elements), and triggers envelope grouping (Build the X12 envelope hierarchy).
| Field | Value |
|---|---|
| Operation ID | OP-05 |
| Trigger | Caller request. |
| Inputs | File path. |
| Outputs | Populated EdiFile with segments and functional-group hierarchy. |
| Primary components | EdiManager.File(), EdiFileBuilder.Path, EdiFileBuilder.Read(), EdiFileReader.Read() |
| Entry point | Common\SAIF.Common.Files\Edi\EdiManager.cs, Common\SAIF.Common.Files\Edi\Core\Builders\EdiFileBuilder.cs, Common\SAIF.Common.Files\Edi\Core\Readers\EdiFileReader.cs |
Steps¶
EdiManager.File()returns a newEdiFileBuilder;Path(path)stores the path and returnsthis(fluent).Read()constructsEdiFileReader { Path = path }and callsRead().- Create
EdiFile, setFileNamefromnew FileInfo(Path).Name. File.ReadAllLines(Path), then trim and concatenate every line into one continuous string — line breaks in the physical file are not significant (BR-017).new EdiSegmentParser().Parse(fileData)— see Parse EDI text into segments and elements.Origin: Step 5 delegates lexical parsing to
EdiSegmentParser.Parse, documented fully in Parse EDI text into segments and elements.file.SetSegments(segments)stores the segments and callsRefreshGroupings()(BR-029, BR-030) — see Build the X12 envelope hierarchy.EdiGroupParser.CreateFunctionalGroups(file)is called again explicitly — redundant with step 6's conditional call.*
Process flow¶
flowchart TD
Start(["Caller: EdiManager.File().Path(p).Read()"]) --> Read[EdiFileReader.Read]
Read --> Concat["File.ReadAllLines +<br>trim/concatenate lines"]
Concat --> Parse["EdiSegmentParser.Parse(fileData)"]
Parse --> Set["EdiFile.SetSegments"]
Set --> Refresh["EdiFile.RefreshGroupings"]
Refresh --> Complete{"ISA, IEA, GS, GE all present?"}
Complete -->|Yes| Groups["EdiGroupParser.CreateFunctionalGroups"]
Complete -->|No| Skip[No functional-group tree built]
Groups --> EndOk([Populated EdiFile returned])
Skip --> EndOk
Failure and edge-case behavior¶
- Physical line wrapping has no semantic effect — a file wrapped at 80 characters and the same file on one line parse identically (BR-017).
- If any of
ISA,IEA,GS,GEis missing,EdiFile.FunctionalGroupsis left unbuilt rather than raising an error (BR-030).
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
- Common\SAIF.Common.Files\Edi\EdiManager.cs
- Common\SAIF.Common.Files\Edi\Core\Builders\EdiFileBuilder.cs
- Common\SAIF.Common.Files\Edi\Core\Readers\EdiFileReader.cs
- Common\SAIF.Common.Files\Edi\EdiFile.cs