Article: Finding Segments – JS

Index

Finding Segments

After an EDILightWeightDocument is initialized by the EDIValidator component, data is stored in a logical structure corresponding to the implementation guides and segments can be retrieved.

Example – Getting a Segment

let doc = ediValidator.EDILightWeightDocument;
 
let interchange = doc.MainSection.getLoop(“INTERCHANGE HEADER”);
//Get ISA segment
let isa = interchange.getSegment(“ISA”);

Example – Getting More Than One Segment

//Get all the REF segments in this loop
let refSegments = loop.getSegments(“REF”);

Example – Drilling To Find Segments

//Get all the REF segments in the 2010BA loop.  Loop 2010BA is a child of ‘parentLoop’
let refSegments = parentLoop.getSegments(“2010BA/REF”);

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

let nm1 =
doc.MainSection.getSegment(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA
/NM1″);
 
let refSegments =
doc.MainSection.getSegments(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA
/REF”);

Related Articles

Main Categories