Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'This is just an example program to show how to translate a UN/EDIFACT ORDERS file in VB.NET
'using the Framework EDI .NET component
Dim oEdiDoc As ediDocument
Dim oSchema As ediSchema
Dim oSchemas As ediSchemas
Dim oSegment As ediDataSegment
Dim sSegmentID As String
Dim sLoopSection As String
Dim nArea As Integer
Dim sValue As String
Dim sNadQlfr As String
Dim sPatQlfr As String
Dim sTaxQlfr As String
Dim sPath As String = AppDomain.CurrentDomain.BaseDirectory
Dim sEdiFile As String = "ORDERS.TXT"
Dim sSefFile As String = "ORDERS_S93A.SEF"
'CREATES EDIDOC OBJECT
ediDocument.Set(oEdiDoc, New ediDocument)
'THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES
'NOT USE ITS BUILT-IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE.
ediSchemas.Set(oSchemas, oEdiDoc.GetSchemas)
oSchemas.EnableStandardReference = False
'THIS OPTIONS STOPS FREDI FROM KEEPING ALL THE SEGMENTS IN MEMORY
oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly
'if edi file does not have a UNA segment, the following terminators are used
oEdiDoc.SegmentTerminator = "'"
oEdiDoc.ElementTerminator = "+"
oEdiDoc.CompositeTerminator = ":"
oEdiDoc.ReleaseIndicator = "?"
'LOADS THE SEF FILE
ediSchema.Set(oSchema, oEdiDoc.LoadSchema(sPath & sSefFile, 0))
'LOADS THE EDI FILE
oEdiDoc.LoadEdi(sPath & sEdiFile)
'GETS THE FIRST DATA SEGMENT
ediDataSegment.Set(oSegment, oEdiDoc.FirstDataSegment)
'LOOP THAT WILL TRAVERSE THRU EDI FILE FROM TOP TO BOTTOM
Do While Not oSegment Is Nothing
'DATA SEGMENTS ARE IDENTIFIED BY THEIR ID, THE LOOP SECTION AND AREA
'(OR TABLE) NUMBER THAT THEY ARE IN.
sSegmentID = oSegment.ID
sLoopSection = oSegment.LoopSection
nArea = oSegment.Area
If nArea = 0 Then
If sLoopSection = "" Then
If sSegmentID = "UNB" Then
sValue = oSegment.DataElementValue(1, 1) 'Syntax identifier
sValue = oSegment.DataElementValue(1, 2) 'Syntax version number
sValue = oSegment.DataElementValue(1, 3) 'Service code list directory version number
sValue = oSegment.DataElementValue(1, 4) 'Character encoding, coded
sValue = oSegment.DataElementValue(2, 1) 'Interchange sender identification
sValue = oSegment.DataElementValue(2, 2) 'Partner identification code qualifier
sValue = oSegment.DataElementValue(2, 3) 'Interchange sender internal identification
sValue = oSegment.DataElementValue(2, 4) 'Interchange sender internal sub-identification
sValue = oSegment.DataElementValue(3, 1) 'Recipient identification
sValue = oSegment.DataElementValue(3, 2) 'Partner identification code qualifier
sValue = oSegment.DataElementValue(3, 3) 'Routing address
sValue = oSegment.DataElementValue(3, 4) 'Interchange Recipient Internal Sub-Identification
sValue = oSegment.DataElementValue(4, 1) 'Date
sValue = oSegment.DataElementValue(4, 2) 'Time
ListBox1.Items.Add(oSegment.DataElement(5).Description + " = " + oSegment.DataElementValue(5)) 'Interchange control reference
sValue = oSegment.DataElementValue(6, 1) 'Recipient reference/password
sValue = oSegment.DataElementValue(6, 2) 'Recipient's reference/password qualifier
sValue = oSegment.DataElementValue(7) 'Application reference
sValue = oSegment.DataElementValue(8) 'Processing priority code
sValue = oSegment.DataElementValue(9) 'Acknowledgement request
sValue = oSegment.DataElementValue(10) 'Interchange Agreement Identifier
sValue = oSegment.DataElementValue(11) 'Test indicator
End If 'sSegmentID
End If 'sLoopSection
ElseIf nArea = 1 Then
If sLoopSection = "" Then
If sSegmentID = "UNH" Then
ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1)) 'Message reference number
sValue = oSegment.DataElementValue(2, 1) 'Message type identifier
sValue = oSegment.DataElementValue(2, 2) 'Message version number
sValue = oSegment.DataElementValue(2, 3) 'Message release number
sValue = oSegment.DataElementValue(2, 4) 'Controlling agency
sValue = oSegment.DataElementValue(2, 5) 'Association assigned code
ElseIf sSegmentID = "BGM" Then
sValue = oSegment.DataElementValue(1, 1) 'Document/message name, coded
sValue = oSegment.DataElementValue(1, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(1, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(1, 4) 'Document/message name
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Document/message name
sValue = oSegment.DataElementValue(3) 'Document/message name
ElseIf sSegmentID = "DTM" Then
sValue = oSegment.DataElementValue(1, 1) 'Date/time/period qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1, 2)) 'Date/time/period
sValue = oSegment.DataElementValue(1, 3) 'Date/time/period format qualifier
ElseIf sSegmentID = "FTX" Then
sValue = oSegment.DataElementValue(1) 'Date/time/period format qualifier
sValue = oSegment.DataElementValue(2) 'Date/time/period format qualifier
sValue = oSegment.DataElementValue(3, 1) 'Free text identification
sValue = oSegment.DataElementValue(3, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 3) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4, 1)) 'Free text
sValue = oSegment.DataElementValue(4, 2) 'Free text
sValue = oSegment.DataElementValue(4, 3) 'Free text
sValue = oSegment.DataElementValue(4, 4) 'Free text
sValue = oSegment.DataElementValue(4, 5) 'Free text
End If 'SegmentID
ElseIf sLoopSection = "RFF" Then
If sSegmentID = "RFF" Then
If oSegment.DataElementValue(1, 1) = "CT" Then 'Contract Number
sValue = oSegment.DataElementValue(1, 1) 'Reference qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1, 2)) 'Reference number
sValue = oSegment.DataElementValue(1, 3) 'Line number
ElseIf oSegment.DataElementValue(1, 1) = "CR" Then 'Customer Reference Number
sValue = oSegment.DataElementValue(1, 1) 'Reference qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1, 2)) 'Reference number
sValue = oSegment.DataElementValue(1, 3) 'Line number
End If
End If 'SegmentID
ElseIf sLoopSection = "NAD" Then
'check the group qualifier to identify the group instance
If sSegmentID = "NAD" Then
sNadQlfr = oSegment.DataElementValue(1) 'Party qualifier
End If
If sNadQlfr = "SE" Then
If sSegmentID = "NAD" Then ' Name and address
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 1)) ' Party identification (3039)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 1) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 2) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 3) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 4) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 5) ' Name and address line (3124)
ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4, 1)) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 2) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 3) ' Party name (3036)
sValue = oSegment.DataElementValue(5, 1) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 2) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 3) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(6) ' City name (3164)
sValue = oSegment.DataElementValue(7) ' Country sub-entity identification (3229)
sValue = oSegment.DataElementValue(8) ' Postcode identification (3251)
sValue = oSegment.DataElementValue(9) ' Country, coded (3207)
ElseIf sSegmentID = "LOC" Then ' Place/location identification
sValue = oSegment.DataElementValue(1) ' Place/location qualifier (3227)
sValue = oSegment.DataElementValue(2, 1) ' Place/location identification (3225)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(2, 4) ' Place/location (3224)
sValue = oSegment.DataElementValue(3, 1) ' Related place/location one identification (3223)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Related place/location one (3222)
sValue = oSegment.DataElementValue(4, 1) ' Related place/location two identification (3233)
sValue = oSegment.DataElementValue(4, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(4, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(4, 4) ' Related place/location two (3232)
sValue = oSegment.DataElementValue(5) ' Relation, coded (5479)
ElseIf sSegmentID = "FII" Then ' Financial institution information
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
sValue = oSegment.DataElementValue(2, 1) ' Account holder number (3194)
sValue = oSegment.DataElementValue(2, 2) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 3) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 4) ' Currency, coded (6345)
sValue = oSegment.DataElementValue(3, 1) ' Institution name identification (3433)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Institution branch number (3434)
sValue = oSegment.DataElementValue(3, 5) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 6) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 7) ' Institution name (3432)
sValue = oSegment.DataElementValue(3, 8) ' Institution branch place (3436)
sValue = oSegment.DataElementValue(4) ' Country, coded (3207)
End If 'sSegmentID
ElseIf sNadQlfr = "BT" Then
If sSegmentID = "NAD" Then ' Name and address
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 1)) ' Party identification (3039)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 1) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 2) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 3) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 4) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 5) ' Name and address line (3124)
ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4, 1)) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 2) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 3) ' Party name (3036)
sValue = oSegment.DataElementValue(5, 1) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 2) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 3) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(6) ' City name (3164)
sValue = oSegment.DataElementValue(7) ' Country sub-entity identification (3229)
sValue = oSegment.DataElementValue(8) ' Postcode identification (3251)
sValue = oSegment.DataElementValue(9) ' Country, coded (3207)
ElseIf sSegmentID = "LOC" Then ' Place/location identification
sValue = oSegment.DataElementValue(1) ' Place/location qualifier (3227)
sValue = oSegment.DataElementValue(2, 1) ' Place/location identification (3225)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(2, 4) ' Place/location (3224)
sValue = oSegment.DataElementValue(3, 1) ' Related place/location one identification (3223)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Related place/location one (3222)
sValue = oSegment.DataElementValue(4, 1) ' Related place/location two identification (3233)
sValue = oSegment.DataElementValue(4, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(4, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(4, 4) ' Related place/location two (3232)
sValue = oSegment.DataElementValue(5) ' Relation, coded (5479)
ElseIf sSegmentID = "FII" Then ' Financial institution information
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
sValue = oSegment.DataElementValue(2, 1) ' Account holder number (3194)
sValue = oSegment.DataElementValue(2, 2) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 3) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 4) ' Currency, coded (6345)
sValue = oSegment.DataElementValue(3, 1) ' Institution name identification (3433)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Institution branch number (3434)
sValue = oSegment.DataElementValue(3, 5) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 6) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 7) ' Institution name (3432)
sValue = oSegment.DataElementValue(3, 8) ' Institution branch place (3436)
sValue = oSegment.DataElementValue(4) ' Country, coded (3207)
End If
ElseIf sNadQlfr = "BY" Then
If sSegmentID = "NAD" Then ' Name and address
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 1)) ' Party identification (3039)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 1) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 2) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 3) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 4) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 5) ' Name and address line (3124)
ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4, 1)) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 2) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 3) ' Party name (3036)
sValue = oSegment.DataElementValue(5, 1) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 2) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 3) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(6) ' City name (3164)
sValue = oSegment.DataElementValue(7) ' Country sub-entity identification (3229)
sValue = oSegment.DataElementValue(8) ' Postcode identification (3251)
sValue = oSegment.DataElementValue(9) ' Country, coded (3207)
ElseIf sSegmentID = "LOC" Then ' Place/location identification
sValue = oSegment.DataElementValue(1) ' Place/location qualifier (3227)
sValue = oSegment.DataElementValue(2, 1) ' Place/location identification (3225)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(2, 4) ' Place/location (3224)
sValue = oSegment.DataElementValue(3, 1) ' Related place/location one identification (3223)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Related place/location one (3222)
sValue = oSegment.DataElementValue(4, 1) ' Related place/location two identification (3233)
sValue = oSegment.DataElementValue(4, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(4, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(4, 4) ' Related place/location two (3232)
sValue = oSegment.DataElementValue(5) ' Relation, coded (5479)
ElseIf sSegmentID = "FII" Then ' Financial institution information
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
sValue = oSegment.DataElementValue(2, 1) ' Account holder number (3194)
sValue = oSegment.DataElementValue(2, 2) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 3) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 4) ' Currency, coded (6345)
sValue = oSegment.DataElementValue(3, 1) ' Institution name identification (3433)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Institution branch number (3434)
sValue = oSegment.DataElementValue(3, 5) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 6) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 7) ' Institution name (3432)
sValue = oSegment.DataElementValue(3, 8) ' Institution branch place (3436)
sValue = oSegment.DataElementValue(4) ' Country, coded (3207)
End If 'sSegmentID
ElseIf sNadQlfr = "ST" Then
If sSegmentID = "NAD" Then ' Name and address
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 1)) ' Party identification (3039)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 1) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 2) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 3) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 4) ' Name and address line (3124)
sValue = oSegment.DataElementValue(3, 5) ' Name and address line (3124)
ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4, 1)) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 2) ' Party name (3036)
sValue = oSegment.DataElementValue(4, 3) ' Party name (3036)
sValue = oSegment.DataElementValue(5, 1) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 2) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(5, 3) ' Street and number/p.o. box (3042)
sValue = oSegment.DataElementValue(6) ' City name (3164)
sValue = oSegment.DataElementValue(7) ' Country sub-entity identification (3229)
sValue = oSegment.DataElementValue(8) ' Postcode identification (3251)
sValue = oSegment.DataElementValue(9) ' Country, coded (3207)
ElseIf sSegmentID = "LOC" Then ' Place/location identification
sValue = oSegment.DataElementValue(1) ' Place/location qualifier (3227)
sValue = oSegment.DataElementValue(2, 1) ' Place/location identification (3225)
sValue = oSegment.DataElementValue(2, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(2, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(2, 4) ' Place/location (3224)
sValue = oSegment.DataElementValue(3, 1) ' Related place/location one identification (3223)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Related place/location one (3222)
sValue = oSegment.DataElementValue(4, 1) ' Related place/location two identification (3233)
sValue = oSegment.DataElementValue(4, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(4, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(4, 4) ' Related place/location two (3232)
sValue = oSegment.DataElementValue(5) ' Relation, coded (5479)
ElseIf sSegmentID = "FII" Then ' Financial institution information
sValue = oSegment.DataElementValue(1) ' Party qualifier (3035)
sValue = oSegment.DataElementValue(2, 1) ' Account holder number (3194)
sValue = oSegment.DataElementValue(2, 2) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 3) ' Account holder name (3192)
sValue = oSegment.DataElementValue(2, 4) ' Currency, coded (6345)
sValue = oSegment.DataElementValue(3, 1) ' Institution name identification (3433)
sValue = oSegment.DataElementValue(3, 2) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 3) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 4) ' Institution branch number (3434)
sValue = oSegment.DataElementValue(3, 5) ' Code list qualifier (1131)
sValue = oSegment.DataElementValue(3, 6) ' Code list responsible agency, coded (3055)
sValue = oSegment.DataElementValue(3, 7) ' Institution name (3432)
sValue = oSegment.DataElementValue(3, 8) ' Institution branch place (3436)
sValue = oSegment.DataElementValue(4) ' Country, coded (3207)
End If 'sSegmentID
End If 'sNadQlfr
ElseIf sLoopSection = "NAD;CTA" Then
If sNadQlfr = "SE" Then
If sSegmentID = "CTA" Then ' Contact information
sValue = oSegment.DataElementValue(1) ' Contact function, coded (3139)
sValue = oSegment.DataElementValue(2, 1) ' Department or employee identification (3413)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 2)) ' Department or employee (3412)
ElseIf sSegmentID = "COM" Then ' Communication contact
sValue = oSegment.DataElementValue(1, 1) ' Communication number (3148)
sValue = oSegment.DataElementValue(1, 2) ' Communication channel qualifier (3155)
End If ' sSegmentID = "COM"
ElseIf sNadQlfr = "BT" Then
If sSegmentID = "CTA" Then ' Contact information
sValue = oSegment.DataElementValue(1) ' Contact function, coded (3139)
sValue = oSegment.DataElementValue(2, 1) ' Department or employee identification (3413)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 2)) ' Department or employee (3412)
ElseIf sSegmentID = "COM" Then ' Communication contact
sValue = oSegment.DataElementValue(1, 1) ' Communication number (3148)
sValue = oSegment.DataElementValue(1, 2) ' Communication channel qualifier (3155)
End If ' sSegmentID = "COM"
ElseIf sNadQlfr = "BY" Then
If sSegmentID = "CTA" Then ' Contact information
sValue = oSegment.DataElementValue(1) ' Contact function, coded (3139)
sValue = oSegment.DataElementValue(2, 1) ' Department or employee identification (3413)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 2)) ' Department or employee (3412)
ElseIf sSegmentID = "COM" Then ' Communication contact
sValue = oSegment.DataElementValue(1, 1) ' Communication number (3148)
sValue = oSegment.DataElementValue(1, 2) ' Communication channel qualifier (3155)
End If ' sSegmentID = "COM"
ElseIf sNadQlfr = "ST" Then
If sSegmentID = "CTA" Then ' Contact information
sValue = oSegment.DataElementValue(1) ' Contact function, coded (3139)
sValue = oSegment.DataElementValue(2, 1) ' Department or employee identification (3413)
ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2, 2)) ' Department or employee (3412)
ElseIf sSegmentID = "COM" Then ' Communication contact
sValue = oSegment.DataElementValue(1, 1) ' Communication number (3148)
sValue = oSegment.DataElementValue(1, 2) ' Communication channel qualifier (3155)
End If ' sSegmentID = "COM"
End If 'sNadQlfr
ElseIf sLoopSection = "TAX" Then
If sSegmentID = "TAX" Then
sValue = oSegment.DataElementValue(1) 'Duty/tax/fee function qualifier
sValue = oSegment.DataElementValue(2, 1) 'Duty/tax/fee type, coded
sValue = oSegment.DataElementValue(2, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 4) 'Duty/tax/fee type
sValue = oSegment.DataElementValue(3, 1) 'Duty/tax/fee account identification
sValue = oSegment.DataElementValue(3, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(4) 'Duty/tax/fee assessment basis
sValue = oSegment.DataElementValue(5, 1) 'Duty/tax/fee rate identification
sValue = oSegment.DataElementValue(5, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(5, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(5, 4) 'Duty/tax/fee rate
sValue = oSegment.DataElementValue(5, 5) 'Duty/tax/fee rate basis identification
sValue = oSegment.DataElementValue(5, 6) 'Code list qualifier
sValue = oSegment.DataElementValue(5, 7) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(6) 'Duty/tax/fee category, coded
ListBox1.Items.Add(oSegment.DataElement(7).Description + " = " + oSegment.DataElementValue(7)) 'Party tax identification number
End If 'SegmentID
ElseIf sLoopSection = "CUX" Then
If sSegmentID = "CUX" Then
sValue = oSegment.DataElementValue(1, 1) 'Currency details qualifier
sValue = oSegment.DataElementValue(1, 2) 'Currency, coded
sValue = oSegment.DataElementValue(1, 3) 'Currency qualifier
sValue = oSegment.DataElementValue(1, 4) 'Currency rate base
End If 'SegmentID
ElseIf sLoopSection = "PAT" Then
If sSegmentID = "PAT" Then
sPatQlfr = oSegment.DataElementValue(1)
End If
If sPatQlfr = "1" Then 'Basic
If sSegmentID = "PAT" Then
sValue = oSegment.DataElementValue(1) 'Payment terms type qualifier
sValue = oSegment.DataElementValue(2, 1) 'Terms of payment identification
sValue = oSegment.DataElementValue(2, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 4) 'Terms of payment
sValue = oSegment.DataElementValue(2, 5) 'Terms of payment
sValue = oSegment.DataElementValue(3, 1) 'Payment time reference, coded
sValue = oSegment.DataElementValue(3, 2) 'Time relation, coded
sValue = oSegment.DataElementValue(3, 3) 'Type of period, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " basic = " + oSegment.DataElementValue(3, 4)) 'Number of periods
ElseIf sSegmentID = "PCD" Then
sValue = oSegment.DataElementValue(1, 1) 'Percentage qualifier
sValue = oSegment.DataElementValue(1, 2) 'Percentage
sValue = oSegment.DataElementValue(1, 3) 'Percentage basis, coded
sValue = oSegment.DataElementValue(1, 4) 'Code list qualifier
sValue = oSegment.DataElementValue(1, 5) 'Code list responsible agency, coded
End If 'SegmentID
ElseIf sPatQlfr = "22" Then 'Discount
If sSegmentID = "PAT" Then
sValue = oSegment.DataElementValue(1) 'Payment terms type qualifier
sValue = oSegment.DataElementValue(2, 1) 'Terms of payment identification
sValue = oSegment.DataElementValue(2, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 4) 'Terms of payment
sValue = oSegment.DataElementValue(2, 5) 'Terms of payment
sValue = oSegment.DataElementValue(3, 1) 'Payment time reference, coded
sValue = oSegment.DataElementValue(3, 2) 'Time relation, coded
sValue = oSegment.DataElementValue(3, 3) 'Type of period, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " discount = " + oSegment.DataElementValue(3, 4)) 'Number of periods
ElseIf sSegmentID = "PCD" Then
sValue = oSegment.DataElementValue(1, 1) 'Percentage qualifier
sValue = oSegment.DataElementValue(1, 2) 'Percentage
sValue = oSegment.DataElementValue(1, 3) 'Percentage basis, coded
sValue = oSegment.DataElementValue(1, 4) 'Code list qualifier
sValue = oSegment.DataElementValue(1, 5) 'Code list responsible agency, coded
End If 'SegmentID
End If
ElseIf sLoopSection = "TDT" Then
If sSegmentID = "TDT" Then
sValue = oSegment.DataElementValue(1) 'Transport stage qualifier
sValue = oSegment.DataElementValue(2) 'Conveyance reference number
sValue = oSegment.DataElementValue(3, 1) 'Mode of transport, coded
sValue = oSegment.DataElementValue(3, 2) 'Mode of transport
sValue = oSegment.DataElementValue(4, 1) 'Type of means of transport identification
sValue = oSegment.DataElementValue(4, 2) 'Type of means of transport
sValue = oSegment.DataElementValue(5, 1) 'Carrier identification
sValue = oSegment.DataElementValue(5, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(5, 3) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(5).Description + " discount = " + oSegment.DataElementValue(5, 4)) 'Carrier name
End If 'SegmentID
ElseIf sLoopSection = "TDT;LOC" Then
If sSegmentID = "LOC" Then
sValue = oSegment.DataElementValue(1) 'Place/location qualifier
sValue = oSegment.DataElementValue(2, 1) 'Place/location identification
sValue = oSegment.DataElementValue(2, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 4) 'Place/location
End If 'SegmentID
ElseIf sLoopSection = "TOD" Then
If sSegmentID = "TOD" Then
sValue = oSegment.DataElementValue(1) 'Terms of delivery or transport function, coded
sValue = oSegment.DataElementValue(2) 'Transport charges method of payment, coded
sValue = oSegment.DataElementValue(3, 1) 'Terms of delivery or transport, coded
sValue = oSegment.DataElementValue(3, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 3) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " discount = " + oSegment.DataElementValue(3, 4)) 'Terms of delivery or transport
sValue = oSegment.DataElementValue(3, 5) 'Terms of delivery or transport
End If 'sSegmentID
End If 'sLoopSection
ElseIf nArea = 2 Then
If sLoopSection = "LIN" Then
If sSegmentID = "LIN" Then
sValue = oSegment.DataElementValue(1) 'Line item number
sValue = oSegment.DataElementValue(2) 'Action request/notification, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " discount = " + oSegment.DataElementValue(3, 1)) 'Item number
sValue = oSegment.DataElementValue(3, 2) 'Item number type, coded
sValue = oSegment.DataElementValue(3, 3) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 4) 'Code list responsible agency, coded
ElseIf sSegmentID = "PIA" Then
sValue = oSegment.DataElementValue(1) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 1) 'Item number
sValue = oSegment.DataElementValue(2, 2) 'Item number type, coded
sValue = oSegment.DataElementValue(2, 3) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 4) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " discount = " + oSegment.DataElementValue(3, 1)) 'Item number
sValue = oSegment.DataElementValue(3, 2) 'Item number type, coded
sValue = oSegment.DataElementValue(3, 3) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 4) 'Code list responsible agency, coded
ElseIf sSegmentID = "IMD" Then
sValue = oSegment.DataElementValue(1) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(3, 1) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 2) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(3).Description + " discount = " + oSegment.DataElementValue(3, 3)) 'Item description
sValue = oSegment.DataElementValue(3, 4) 'Item description
ElseIf sSegmentID = "QTY" Then
sValue = oSegment.DataElementValue(1, 1) 'Quantity qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " discount = " + oSegment.DataElementValue(1, 2)) 'Quantity
sValue = oSegment.DataElementValue(1, 3) 'Measure unit qualifier
ElseIf sSegmentID = "DTM" Then
sValue = oSegment.DataElementValue(1, 1) 'Date/time/period qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " discount = " + oSegment.DataElementValue(1, 2)) 'Date/time/period
sValue = oSegment.DataElementValue(1, 3) 'Date/time/period format qualifier
ElseIf sSegmentID = "FTX" Then
sValue = oSegment.DataElementValue(1) 'Date/time/period format qualifier
sValue = oSegment.DataElementValue(2) 'Date/time/period format qualifier
sValue = oSegment.DataElementValue(3, 1) 'Free text identification
sValue = oSegment.DataElementValue(3, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 3) 'Code list responsible agency, coded
ListBox1.Items.Add(oSegment.DataElement(4).Description + " discount = " + oSegment.DataElementValue(4, 1)) 'Free text
sValue = oSegment.DataElementValue(4, 2) 'Free text
sValue = oSegment.DataElementValue(4, 3) 'Free text
sValue = oSegment.DataElementValue(4, 4) 'Free text
sValue = oSegment.DataElementValue(4, 5) 'Free text
End If 'SegmentID
ElseIf sLoopSection = "LIN;PRI" Then
If sSegmentID = "PRI" Then
sValue = oSegment.DataElementValue(1, 1) 'Price qualifier
sValue = oSegment.DataElementValue(1, 2) 'Price
sValue = oSegment.DataElementValue(1, 3) 'Price type, coded
sValue = oSegment.DataElementValue(1, 4) 'Price type qualifier
sValue = oSegment.DataElementValue(1, 5) 'Unit price basis
sValue = oSegment.DataElementValue(1, 6) 'Measure unit qualifier
End If 'SegmentID
ElseIf sLoopSection = "LIN;TAX" Then
If sSegmentID = "TAX" Then
sTaxQlfr = oSegment.DataElementValue(1)
End If
If sTaxQlfr = "7" Then 'Tax
If sSegmentID = "TAX" Then
sValue = oSegment.DataElementValue(1) 'Duty/tax/fee function qualifier
sValue = oSegment.DataElementValue(2, 1) 'Duty/tax/fee type, coded
sValue = oSegment.DataElementValue(2, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(2, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(2, 4) 'Duty/tax/fee type
sValue = oSegment.DataElementValue(3, 1) 'Duty/tax/fee account identification
sValue = oSegment.DataElementValue(3, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(3, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(4) 'Duty/tax/fee assessment basis
sValue = oSegment.DataElementValue(5, 1) 'Duty/tax/fee rate identification
sValue = oSegment.DataElementValue(5, 2) 'Code list qualifier
sValue = oSegment.DataElementValue(5, 3) 'Code list responsible agency, coded
sValue = oSegment.DataElementValue(5, 4) 'Duty/tax/fee rate
sValue = oSegment.DataElementValue(5, 5) 'Duty/tax/fee rate basis identification
sValue = oSegment.DataElementValue(5, 6) 'Code list qualifier
sValue = oSegment.DataElementValue(5, 7) 'Code list responsible agency, coded
ElseIf sSegmentID = "MOA" Then
sValue = oSegment.DataElementValue(1, 1) 'Monetary amount type qualifier
ListBox1.Items.Add(oSegment.DataElement(1).Description + " tax = " + oSegment.DataElementValue(1, 2)) 'Monetary amount
sValue = oSegment.DataElementValue(1, 3) 'Currency, coded
sValue = oSegment.DataElementValue(1, 4) 'Currency qualifier
sValue = oSegment.DataElementValue(1, 5) 'Status, coded
End If 'sSegmentID
End If
End If 'sLoopSection
ElseIf nArea = 3 Then
If sLoopSection = "" Then
If sSegmentID = "UNS" Then
sValue = oSegment.DataElementValue(1) 'Section identification
End If 'sSegmentID
End If 'sLoopSection
End If 'nArea
'GETS THE NEXT DATA SEGMENT
ediDataSegment.Set(oSegment, oSegment.Next)
Loop
'DESTROY OBJECTS
oSchema.Dispose()
oSchemas.Dispose()
oEdiDoc.Dispose()
End Sub