WSEDI Level 2
Apr 13th, 2007 by Ricker
Nested Representation
X12 and EDIFACT both contain the implied (or interpreted) structure of loops within the messages. A loop is a set of associated segments. Generally, if the first segment of a loop appears in a message, then the other segments of the loop should also appear.
The most common example of a loop is a mailing address. In X12, an address loop will usually contain the following segments:
- N1 Name
- N2 Additional Name Information
- N3 Address Information
- N4 Geographic Location
- NX2 Location ID Component
- REF Reference Identification
- PER Administrative Communications Contact
It is very convenient to be able to handle segments within a loop collectively. Grouping segments of a loop aids in understanding, processing and displaying WS-EDI messages. As such, WS-EDI Level 2 representation introduces a loop structure.
Loop
Not all segments belong to a loop. Loops can contain segments and other loops. We identify a loop by the first segment contained in the loop. With these points in mind, consider the following schema change for WS-EDI Level 2:
<!ELEMENT wsedi ((segment|loop)+)> <!ELEMENT loop (segment,(segment|loop)*)> <!ATTLIST loop code CDATA #REQUIRED>
An address loop, or N1 loop, in X12 would look something like the fragment provided here:
<wsedi> ... <loop code="N1"> <segment code="N1">... <segment code=”N2″>… <segment code=”N3″>… <segment code=”N4″>… </loop>
Interchanges and functional groups
EDI documents can contain several messages. The EDI document or file itself is called an interchange. An interchange will contain one or more functional groups. A functional group will contain one or more messages. In a simple EDI document, we would have one interchange containing one functional group containing one message. Sometimes EDI is not so simple.
The following document fragment shows how WS-EDI Level 2 would represent the document nesting of an EDIFACT message.
<wsedi>
<segment code="UNA" name="Service String Advice"/>
<segment code="UNB" name="Interchange Header"/>
<loop code="UNG">
<segment code="UNG" name="Functional Group Header"/>
<loop code="UNH">
<segment code="UNH" name="Message Header"/>
... segments and loops of message ...
<segment code="UNT" name="Message Trailer"/>
</loop>
<segment code="UNE" name="Functional Group Trailer"/>
</loop>
<segment code="UNZ" name="Interchange Trailer"/>
</wsedi>
The WS-EDI document could contain more than one UNG loop and each UNG loop could contain several UNH loops.
The following fragment shows the document nesting structure for X12.
<wsedi>
<segment code="ISA" name="Interchange Header"/>
<loop code="GS">
<segment code="GS" name="Functional Group Header"/>
<loop code="ST">
<segment code="ST" name="Message Header"/>
... segments and loops of message ...
<segment code="SE" name="Message Trailer"/>
</loop>
<segment code="GE" name="Functional Group Trailer"/>
</loop>
<segment code="IEA" name="Interchange Trailer"/>
</wsedi>
Example documents
- An UN EDIFACT document and its Level 2 representation.
- An ANSI X12 document and its Level 2 representation.
Leave a Reply
You must be logged in to post a comment.