Electronic Data Interchange | |
The Interchange Header (UN/EDIFACT) |
The Interchange Header is the starting control segment of the interchange envelope. After the recipient has received the document, the interchange header is the first data segment encountered in the document. The interchange header contains:
This topic covers:
Interchange Header in a Document
In the document, the interchange header is identified with the first letters "UNB" followed by the element separator.
The interchange header data stream fit into the implementation guideline defined for the interchange header as follows:
REF ELE NAME REQ TYPE MIN/MAX VALUE COMMENT 01 S001 Syntax Identifier M Composite element indicating the Syntax Version. 01 0001 Syntax Identifier M A 4/4 UNOB This value indicates UN/ECE Syntax Level B is used in the interchange. 02 0002 Syntax Version Number M AN 1/1 4 This value indicates Syntax Version 4 is used in the interchange. 02 S002 Interchange Sender M Composite element identifying the sender of the interchange. 01 0004 Interchange Sender Identification M A 4/4 SENDERID 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/1 ZZ This element qualifies element 0004. The value "ZZ" indicates that the sender identification at 0004 is mutually defined which means it only has meaning to the trading partner. 03 S003 Interchange Recipient M Composite element identifying the recipient of the interchange. 01 0010 Recipient Identification M A 4/4 RECIPIENTID This value is the identity of the recipient. Its meaining is qualified by the associated component element 0007. 02 0007 Partner Identification Code Qualifier C AN 1/1 ZZ This element qualifies element 0010. The value "ZZ" indicates that the recipient identification at 0010 is mutually defined which means it only has meaning to the trading partner. 04 S004 Date and Time of Preparation M Composite element indicating the date and time the interchange was prepared. 01 0017 Date M AN 8/8 20090419 The date the interchange was prepared. 02 0019 Time M AN 4/4 1230 The time the interchange was prepared. 05 0020 Interchange Control Reference M AN 10/10 1 Unique control number assigned to the interchange. 06 S005 Recipient Reference/Password Details C Composite element indicating the date and time the interchange was prepared. 01 0022 Recipient Reference/Password M A 1/14 MYPASSWORD The date the interchange was prepared. 02 0025 Recipient Reference/Password Qual M AN 2/2 BB The time the interchange was prepared. 07 0026 Application Reference C AN 1/14 INVOIC This value is used to aid processing of the interchange by some application, department, etc. 08 0029 Processing Priority Code C A 1/1 A The value "A" is a predefined code that indicates that the interchange is to be processed with highest priority. 09 0031 Acknowledgment Request C N 1/1 1 The value "1" is a predefined code that requests acknowledgment of interchange when it is received. 10 0032 Interchange Agreement Identifier C AN 1/35 No value is assigned but present to keep data elements that follow it and have value to maintain their position in the segment. 11 0035 Test Indicator C N 1/1 1 The value "1" is a predefined code that indicates the interchange is for testing only.
Programmatically Reading the Interchange Header
The following steps demonstrates how to read 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 & "\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
' Get interchange 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 = oInterchange.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 Interchange Header
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 & "\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 Interchange envelope.
Set oInterchange = oEdiDoc.CreateInterchange("UN", "D08A")
Dim oHeader As Fredi.ediDataSegment
' Get the interchange 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) = "20090419"
oHeader.DataElementValue(4, 2) = "1230"
oHeader.DataElementValue(5) = "1"
oHeader.DataElementValue(7) = "INVOIC"
oHeader.DataElementValue(11) = "1"