Finding Loops
Example – Getting A Loop
Typed5010Document doc = new Typed5010Document(ediValidator.EDILightWeightDocument);
//Get the Interchange Header loop
DocumentLoop interchange = doc.MainSection.GetLoop(“INTERCHANGE HEADER”);
Example – Getting More Than One Loop
//Get all the 2000B loops in ‘parentLoop’
List<DocumentLoop> all2000BLoops = parentLoop.GetLoops(“2000B”);
Example – Drilling To Get Loops
//Get all the 2000B loops in loop 2000A of ‘parentLoop’
List<DocumentLoop> all2000BLoops = parentLoop.GetLoops(“2000A/2000B”);
Notice the forward slash (‘/’) operator is used to drill into loops. Use as many forward slashes as required to get to the loop(s) required
Example
DocumentLoop loop2010AA =
doc.MainSection.GetLoop(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA”);
List<DocumentLoop> all2010AALoops =
doc.MainSection.GetLoops(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA”);
Finding Typed Segments
Example – Getting A Segment
Typed5010Document doc = new Typed5010Document(ediValidator.EDILightWeightDocument);
DocumentLoop interchange = doc.MainSection.GetLoop(“INTERCHANGE HEADER”);
//Get ISA segment
ISA isa = interchange.GetSegment<ISA>();
Example – Getting More Than One Segment Of The Same Type
//Get all the REF segments in this loop
List<REF> refSegments = loop.GetSegments<REF>(“REF”);
foreach (REF segment in refSegments){
}
Example – Drilling To Find Segments
//Get all the REF segments in the 2010BA loop. Loop 2010BA is a child of ‘parentLoop’
List<REF> refSegments = parentLoop.GetSegments<REF>(“2010BA/REF”);
foreach (REF segment in refSegments){
}
Notice the forward slash (‘/’) operator is used to drill into loops. Use as many forward slashes as required to get to the segment(s) required.
Example
NM1 nm1 =
doc.MainSection.GetSegment<NM1>(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA
/NM1″);
List<REF> refSegments =
doc.MainSection.GetSegments<REF>(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA
/REF”);