| EDIdEv - Electronic Data Interchange Development | EDIdEv | |
|
EDI Tool for Developers | |
|
Application How it Works
After the translation is complete, the data of the EDI file will be displayed along with its descriptions, which makes the EDI file easier to read and understand as shown below.
You can change the description of the segments and elements in the SEF file with our SEF Manager utility to make their descriptions even more detailed and specific so that it can be more fully understood. For example, an N1 segment's generic description of Name can be changed to Ship-To Name.
(For more details about editing a SEF file with our SEF Manager, please visit http://www.edidev.com/articles/createIG/HowToCreateIG.html) After the translation, any errors found in the EDI file will be reported at the end of the document. The Segment Index is the segment count location where the particular error occurred.
The Visual
Basic Script Sub ReadEDIfile() ' ' ReadEDIfile Macro ' Macro created 5/3/2009 by edidev ' Dim oEdiDoc As ediDocument Dim oSegment As ediDataSegment Dim oElement As ediDataElement Dim oElements As ediDataElements Dim oSubElement As ediDataElement Dim oWarnings As ediWarnings Dim oWarning As ediWarning Dim oSchemas As ediSchemas Dim sPath As String Dim i As Integer Dim ii As Integer Dim sSefFile As String Dim sEdifile As String Dim nErrCount As Integer Set oEdiDoc = New ediDocument Set oSchemas = oEdiDoc.GetSchemas 'enable read of modified description in SEF file oSchemas.Option(OptSchemas_IncludeText) = 1 oEdiDoc.CursorType = Cursor_ForwardOnly sPath = Application.ActiveDocument.Path & "\" 'get and load SEF file sSefFile = InputBox("Enter SEF filename", "SEF File", "810_4010_modified.SEF") oEdiDoc.LoadSchema sPath & sSefFile, Schema_Standard_Exchange_Format 'get and load EDI file sEdifile = InputBox("Enter EDI filename", "EDI File", "810.X12") oEdiDoc.LoadEdi sPath & sEdifile 'traverse EDI file Set oSegment = oEdiDoc.FirstDataSegment Do While Not oSegment Is Nothing Selection.Font.Bold = wdToggle Selection.TypeText oSegment.ID & " - " & UCase(oSegment.Description) & vbCrLf Selection.Font.Size = 8 Selection.TypeText oSegment.SegmentBuffer + vbCrLf Selection.Font.Bold = wdToggle Selection.Font.Reset nElemCount = oSegment.Count For i = 1 To nElemCount Set oElement = oSegment.DataElement(i) Set oElements = oElement.DataElements nSubElemCount = oElements.Count If nSubElemCount > 1 Then 'Composite Element For ii = 1 To nSubElemCount If Len(Trim(oSegment.DataElementValue(i, ii))) > 0 Then Set oSubElement = oElements.DataElement(ii) Selection.TypeText oSubElement.Description & ": " Selection.Font.Italic = wdToggle Selection.TypeText oSegment.DataElementValue(i, ii) & vbCrLf Selection.Font.Italic = wdToggle End If Next Else 'Not a composite element If Len(Trim(oSegment.DataElementValue(i))) > 0 Then Selection.TypeText oElement.Description & ": " Selection.Font.Italic = wdToggle Selection.TypeText oSegment.DataElementValue(i) & vbCrLf Selection.Font.Italic = wdToggle End If End If Next Selection.TypeText "" + vbCrLf 'get next segment Set oSegment = oSegment.Next Loop Selection.TypeText "" & vbCrLf Selection.TypeText "" & vbCrLf Selection.TypeText "" & vbCrLf Selection.Font.Bold = wdToggle Selection.TypeText "Error messages" & vbCrLf Selection.Font.Bold = wdToggle 'check for errors Set oWarnings = oEdiDoc.GetWarnings nErrCount = oWarnings.Count If nErrCount > 0 Then For i = 1 To nErrCount Set oWarning = oWarnings.Warning(i) Selection.TypeText oWarning.Description & " " Selection.Font.Bold = wdToggle Selection.TypeText "Segment Index:" & oWarning.SegmentIndex & vbCrLf Selection.Font.Bold = wdToggle Selection.TypeText "" & vbCrLf Next Else Selection.TypeText "No errors found" End If Selection.Font.Reset End Sub
|
EDIdEv - EDI Development
www.edidev.com