Electronic Data Interchange | |
The Interchange Trailer (ASC/X12) |
The Interchange Trailer ends transmission of an interchange. It contains:
This topic covers:
Interchange Trailer in a document
In the document the interchange trailer is identifier by it segment identifier "IEA" followed by the data element separator.
The interchange trailer data stream fit into the implementation guideline defined for the interchange trailer as follows:
REF ELE NAME REQ TYPE MIN/MAX VALUE COMMENT 01 I16 Number of Included Functional Groups M N0 1/5 1 This value indicates the number of functional groups that are enveloped by the interchange at the time that it was prepared. 02 I12 Interchange Control Number M N0 1/9 000000020 This is the control number that associates the interchange trailer with its interchange header pair that has a matching control number.
Programmatically Reading the Interchange Trailer
The following steps demonstrates how to read the interchange trailer.
Dim oEdiDoc As Fredi.ediDocument
Set oEdiDoc = New Fredi.ediDocument
Dim oSchemas As Fredi.ediSchemas
Dim oSchema As Fredi.ediSchema
' Disable standard reference library.
Set oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = False
Set oSchema = oEdiDoc.LoadSchema(App.Path & "\SampleAscX12_850.SEF", Schema_Standard_Exchange_Format)
' Load EDI document normally.
oEdiDoc.LoadEdi App.Path & "\SampleEdiX12_850.X12"
Dim oInterchange As Fredi.ediInterchange
' Get first interchange.
Set oInterchange = oEdiDoc.FirstInterchange
' Get interchange header.
Dim oTrailer As Fredi.ediDataSegment
Dim oElements As Fredi.ediDataElements
Dim oElement As Fredi.ediDataElement
Dim sResult As String
Dim i As Integer
Set oTrailer = oInterchange.GetDataSegmentTrailer
' Get elements collection.
Set oElements = oTrailer.DataElements
sResult = ""
For Each oElement In oElements
sResult = sResult & oElement.ID & " = " & oElement.Value & vbCrLf
Next
Programmatically Generating the Interchange Trailer
The following steps demonstrates how to generate the interchange header.
Dim oEdiDoc As Fredi.ediDocument
Set oEdiDoc = New Fredi.ediDocument
Dim oSchemas As Fredi.ediSchemas
Dim oSchema As Fredi.ediSchema
' Disable standard reference library.
Set oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = False
Set oSchema = oEdiDoc.LoadSchema(App.Path & "\SampleAscX12_850.SEF", Schema_Standard_Exchange_Format)
' Specify the terminators to use on the document.
oEdiDoc.SegmentTerminator = vbCrLf
oEdiDoc.ElementTerminator = "*"
oEdiDoc.CompositeTerminator = ">"
Dim oInterchange As Fredi.ediInterchange
' Create the Interchange envelope.
Set oInterchange = oEdiDoc.CreateInterchange("X", "004010")
Dim oTrailer As Fredi.ediDataSegment
' Get the interchange header.
Set oTrailer = oInterchange.GetDataSegmentTrailer
' Set the values of the elements.