Electronic Data Interchange | |
The UNA Service String Advice (UN/EDIFACT) |
EDI documents can specify a Service String Advice (UNA) segment at the top of the document. The UNA specifies all the service characters to be used in the document, and is specified only if the service characters differ from the default characters.
This topic covers:
The UNA segment is a fixed length, nine character string that contain only service characters that must be used to process the document. The characters must be in the following order:
For example, the string "UNA:+.?*'" can be broken down to:
If present in the document, the UNA segment would appear at the beginning of the document as follows:
Programming the Service String Advice (UNA) segment
The following steps demonstrates how an EDIFACT document is generated with a UNA Service String Advice.
Dim oEdiDoc As Fredi.ediDocument
Set oEdiDoc = New Fredi.ediDocument
' Enable UNA Service String Advice.
oEdiDoc.Option(OptDocument_ServiceSegment) = 1
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 = "?"
' Create the Interchange envelope.
Set oInterchange = oEdiDoc.CreateInterchange("UN", "D96A")
' Gets the UNB segment (created above), then set values.
Set oSegment = oInterchange.GetDataSegmentHeader
oSegment.DataElementValue(1, 1) = "M001"
oSegment.DataElementValue(2, 1) = "123"
oSegment.DataElementValue(2, 2) = "ZZ"
oSegment.DataElementValue(3, 1) = "00123"
oSegment.DataElementValue(3, 2) = "01"
oSegment.DataElementValue(3, 3) = "ABC123"
oSegment.DataElementValue(4, 1) = "020331"
oSegment.DataElementValue(4, 2) = "1230"
oSegment.DataElementValue(5) = "00000000000001"
oSegment.DataElementValue(7) = "INVOIC"
oSegment.DataElementValue(11) = "1"
' Create the Message envelope.
Set oMessage = oInterchange.CreateMessage("INVOIC")
' Gets the UNH segment (created above), then set values.
Set oSegment = oMessage.GetDataSegmentHeader
oSegment.DataElementValue(1) = "M001"
oSegment.DataElementValue(2, 1) = "INVOIC"
oSegment.DataElementValue(2, 2) = "D"
oSegment.DataElementValue(2, 3) = "96A"
oSegment.DataElementValue(2, 4) = "UN"
oSegment.DataElementValue(11) = "1"
' Create data segments in the Message.
Set oSegment = oMessage.CreateDataSegment("BGM")
oSegment.DataElementValue(1, 1) = "82"
oSegment.DataElementValue(2) = "199889"
oSegment.DataElementValue(3) = "9"
Set oSegment = oMessage.CreateDataSegment("DTM")
oSegment.DataElementValue(1, 1) = "137"
oSegment.DataElementValue(2) = "19990608"
oSegment.DataElementValue(3) = "102"
Set oSegment = oMessage.CreateDataSegment("DTM(2)")
oSegment.DataElementValue(1, 1) = "263"
oSegment.DataElementValue(1, 2) = "199905"
oSegment.DataElementValue(1, 3) = "610"
Set oSegment = oMessage.CreateDataSegment("PAI")
oSegment.DataElementValue(1, 3) = "42"
Set oSegment = oMessage.CreateDataSegment("RFF\RFF")
oSegment.DataElementValue(1, 1) = "AAJ"
oSegment.DataElementValue(1, 2) = "99899"
' Save to an output file.
oEdiDoc.Save App.Path & "\Output.txt"