'This is just an example program to demonstrate how to translate a 997 EDI file in Visual Basic using the Framework EDI Option Explicit Private oEdiDoc As Fredi.ediDocument Private oSegment As Fredi.ediDataSegment Private oSchemas As Fredi.ediSchemas Private sSegmentID As String Private sLoopSection As String Private nArea As String Private sTsCode As String Private Sub cmdTranslate_Click() Dim sPath As String Dim sFgControlNo As String Dim sFgCode As String Dim sTsControlNo As String Dim sTsCode As String Me.MousePointer = vbHourglass sPath = App.Path & "\" Set oEdiDoc = New Fredi.ediDocument 'Disable the internal Standard Reference, and obtain schema from SEF files only Set oSchemas = oEdiDoc.GetSchemas oSchemas.EnableStandardReference = False 'ForwardOnly cursor type does not keep the entire EDI file in memory. Saves RAM and improves performance oEdiDoc.CursorType = Cursor_ForwardOnly 'Load the SEF file oEdiDoc.ImportSchema sPath & "997_X12-4010.SEF", Schema_Standard_Exchange_Format 'Load the EDI file oEdiDoc.LoadEdi sPath & "997_810.X12" 'Traverse through the EDI file a segment at a time 'Get the first data segment Set oSegment = oEdiDoc.FirstDataSegment Do While Not oSegment Is Nothing 'segments are identified by their area, loop section they are in, and segment id nArea = oSegment.Area sLoopSection = oSegment.LoopSection sSegmentID = oSegment.ID If nArea = 0 Then If sSegmentID = "ISA" Then ' ElseIf sSegmentID = "GS" Then ' End If ElseIf nArea = 1 Then If sLoopSection = "" Then If sSegmentID = "AK1" Then sFgCode = oSegment.DataElementValue(1) sFgControlNo = oSegment.DataElementValue(2) ElseIf sSegmentID = "AK9" Then If oSegment.DataElementValue(1) = "A" Then MsgBox "Functional Group '" & sFgCode & "' Control No. '" & sFgControlNo & "' was accepted." Else MsgBox "Functional Group '" & sFgCode & "' Control No. '" & sFgControlNo & "' was rejected." End If End If ElseIf sLoopSection = "AK2" Then If sSegmentID = "AK2" Then sTsCode = oSegment.DataElementValue(1) sTsControlNo = oSegment.DataElementValue(2) ElseIf sSegmentID = "AK5" Then If oSegment.DataElementValue(1) = "A" Then MsgBox "Transaction '" & sTsCode & "' Control No. '" & sTsControlNo & "' in Functional Group '" & sFgCode & "' Control No. '" & sFgControlNo & "' was accepted" Else MsgBox "Transaction '" & sTsCode & "' Control No. '" & sTsControlNo & "' in Functional Group '" & sFgCode & "' Control No. '" & sFgControlNo & "' was rejected" End If End If End If End If 'get next data segment Set oSegment = oSegment.Next Loop Me.MousePointer = vbNormal MsgBox "Done" cmdTranslate.Enabled = False End Sub