Electronic Data Interchange | ![]() |
The Group Header (UN/EDIFACT) |
The Group Header is the starting control segment of the group envelope. The group header contains:
This topic covers:
In the document, the group header is identified with the first letters "UNG" followed by the element separator.
The group header data stream fit into the implementation guideline defined for the group header as follows:
REF ELE NAME REQ TYPE MIN/MAX VALUE COMMENT 01 0038 Message Group Identification C AN 1/6 ID Identifier that identifies the messages or packages enveloped by the group into some particular type. 02 S006 Application Sender Identification C Composite element identifying the sender of the group. 01 0040 Application Sender Identification M AN 1/35 APPSENDER This value is the identity of the sender. Its meaning is qualified by the associated component element 0007. 02 0007 Partner Identification Code Qualifier C AN 1/4 ZZZ This element qualifies element 0040. The value "ZZZ" indicates that the sender identification at 0040 is mutually defined which means it only has meaning to the trading partner. 03 S007 Application Recipient Identification C Composite element identifying the receiver of the group. 01 0004 Application Recipient Identification M AN 1/35 APPRECEIVER This value is the identity of the recipient. Its meaning is qualified by the associated component element 0007. 02 0007 Partner Identification Code Qualifier C AN 1/4 ZZZ This element qualifies element 0004. The value "ZZZ" indicates that the sender identification at 0004 is mutually defined which means it only has meaning to the trading partner. 04 S004 Date and Time of Preparation C Composite element indicating the date and time the group was prepared. 01 0017 Date M N 8/8 20090419 The date the group was prepared. 02 0019 Time M N 4/4 1230 The time the group was prepared. 05 0048 Group Reference Reference C AN 1/14 1 Unique group reference number assigned to the group. This number is unique to the group within the interchange. 06 0051 Controlling Agency C AN 1/3 UN Controlling Agency (UN/CEFACT) 07 S008 Message Version C Composite element indicating the version of the message to use. 01 0052 Message Version Number M AN 1/3 D The major of the message. 02 0054 Message Release Number M AN 1/3 08A The release of the message. 03 0057 Association Assigned Code C AN 1/6 08 0058 Application Password C AN 1/14
Programmatically Reading the Group Header
The following steps demonstrates how to read 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 & "\EDIFACT_INVOIC.SEF", Schema_Standard_Exchange_Format)
' Load EDI document normally.
oEdiDoc.LoadEdi App.Path & "\SampleEdifactDoc.EDI"
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 oHeader As Fredi.ediDataSegment
Dim oElements As Fredi.ediDataElements
Dim oElement As Fredi.ediDataElement
Dim sResult As String
Dim i As Integer
Set oHeader = oGroup.GetDataSegmentHeader
' Get elements collection.
Set oElements = oHeader.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 Header
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 & "\EDIFACT_INVOIC.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 oHeader As Fredi.ediDataSegment
' Get the group header.
Set oHeader = oInterchange.GetDataSegmentHeader
' Set the values of the elements.
oHeader.DataElementValue(1, 1) = "UNOB"
oHeader.DataElementValue(1, 2) = "4"
oHeader.DataElementValue(2, 1) = "123"
oHeader.DataElementValue(2, 2) = "ZZ"
oHeader.DataElementValue(3, 1) = "00123"
oHeader.DataElementValue(3, 2) = "01"
oHeader.DataElementValue(3, 3) = "ABC123"
oHeader.DataElementValue(4, 1) = "020331"
oHeader.DataElementValue(4, 2) = "1230"
oHeader.DataElementValue(5) = "1"
oHeader.DataElementValue(7) = "INVOIC"
oHeader.DataElementValue(11) = "1"< BR >
Dim oGroup As Fredi.ediGroup
' Create the Group envelope.
Set oGroup = oInterchange.CreateGroup("D08A")
Dim oHeader As Fredi.ediDataSegment
' Get the group header.
Set oHeader = oGroup.GetDataSegmentHeader
' Set the values of the elements.
oHeader.DataElementValue(1) = "ID"
oHeader.DataElementValue(2, 1) = "APPSENDER"
oHeader.DataElementValue(2, 2) = "ZZZ"
oHeader.DataElementValue(3, 1) = "APPRECEIVER"
oHeader.DataElementValue(3, 2) = "ZZZ"
oHeader.DataElementValue(4, 1) = "20090419"
oHeader.DataElementValue(4, 2) = "1230"
oHeader.DataElementValue(5) = "1"
oHeader.DataElementValue(6) = "UN"
oHeader.DataElementValue(7, 1) = "D"
oHeader.DataElementValue(7, 2) = "08A"