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

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.

  1. Create an instance of ediDocument.

    Dim oEdiDoc As Fredi.ediDocument

    Set oEdiDoc = New Fredi.ediDocument

  2. Enables the option to generate an UNA segment. The UNA segment is controlled using the option OptDocument_ServiceSegment in the ediDocument interface 

    ' Enable UNA Service String Advice.
    oEdiDoc.Option(OptDocument_ServiceSegment) = 1

  3. Load the schema.

    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)

  4. Specify the terminators to use on the document.

    ' Specify the terminators to use on the document.
    oEdiDoc.SegmentTerminator = "'" & vbCrLf
    oEdiDoc.ElementTerminator = "+"
    oEdiDoc.CompositeTerminator = ":"
    oEdiDoc.ReleaseIndicator = "?"

  5. Create the Interchange envelope.

    ' 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"

  6. Create the Message envelope.

    ' 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"

  7. Create data segments in the Message.

    ' 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"

  8. Save the document to an output file.

    ' Save to an output file.
    oEdiDoc.Save App.Path & "\Output.txt"