Electronic Data Interchange | |
The Group Trailer (UN/EDIFACT) |
The Group Trailer ends transmission of the group envelope. It contains:
This topic covers:
In the document the group trailer is identifier by it segment identifier "UNZ" followed by the data element separator.
The group trailer data stream fit into the implementation guideline defined for the group trailer as follows:
REF ELE NAME REQ TYPE MIN/MAX VALUE COMMENT 01 0060 Group Control Count M N 1/6 1 This value indicates the number of messages or packages that are enveloped by the group at the time that it was prepared. 02 0048 Group Reference Number M AN 1/14 1 This is the control number that associates the group trailer with its group header pair that has a matching reference number.
Programmatically Reading the Group Trailer
The following steps demonstrates how to read the group 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 & "\EDIFACT_INVOIC.SEF", Schema_Standard_Exchange_Format)
' Load EDI document normally.
oEdiDoc.LoadEdi App.Path & "\SampleEdifactDoc.X12"
Dim oInterchange As Fredi.ediInterchange
' Get first interchange.
Set oInterchange = oEdiDoc.FirstInterchange
Dim oGroup As Fredi.ediInterchange
' Get first group.
Set oGroup = oInterchange.FirstGroup
' Get group 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 = oGroup.GetDataSegmentTrailer
' Get elements collection.
Set oElements = oTrailer.DataElements
sResult = ""
For Each oElement In oElements
Dim oSubElements As Fredi.ediDataElementsNext
Dim oSubElement As Fredi.ediDataElement
Set oSubElements = oElement.DataElements
If oSubElements.Count > 0 Then' Read component elements.Else
sResult = sResult & vbTab & oElement.ID & vbCrLf
For Each oSubElement In oSubElementssResult = sResult & vbTab & vbTab & oSubElement.ID & " = " & oSubElement.Value & vbCrLfNext
sResult = sResult & vbTab & oElement.ID & " = " & oElement.Value & vbCrLfEnd If
Programmatically Generating the Group Trailer
The following steps demonstrates how to generate the group 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 & "\SampleINVOICE.SEF", Schema_Standard_Exchange_Format)
' Specify the terminators to use on the document.
oEdiDoc.SegmentTerminator = "'" & vbCrLf
oEdiDoc.ElementTerminator = "+"
oEdiDoc.CompositeTerminator = ":"
oEdiDoc.ReleaseIndicator = "?"
Dim oInterchange As Fredi.ediInterchange
' Create the Group envelope.
Set oInterchange = oEdiDoc.CreateInterchange("UN", "D08A")
Dim oGroup As Fredi.ediGroup
' Create the Group envelope.
Set oGroup = oInterchange.CreateGroup("D08A")
Dim oTrailer As Fredi.ediDataSegment
' Get the group header.
Set oTrailer = oGroup.GetDataSegmentTrailer
' Set the values of the elements.