Electronic Data Interchange | |
Procedure for Translating an ASC/X12 Document without any SEF |
This procedure describes how one can translate an ASC/X12 Purchase Order (850) document without having to use any Standard Exchange Format (SEF) file. Framework EDI (FRED) requires an implementation guideline to translate and generate EDI files, and, if none is specified, then the internal standard reference library is used. FREDI determines the best guideline to use based on the information in the EDI file. It is always preferable to use a SEF file and not the standard reference library so that the user knows exactly what guideline is used. Using a SEF file also provides better performance. In this procedure, no SEF file is used and so FREDI will determine the best guideline to use in the internal standard reference library. The procedure is as follows:
Example in Visual Basic
This example will use the following:
Create an instance of ediDocument. The ediDocument object is the top level application instance for FREDI. This object is the topmost object in the object model hierarchy of FREDI. This instance is always created at the start of a program.
Dim oEdiDoc As Fredi.ediDocument
Set oEdiDoc = New Fredi.ediDocument
Load EDI document. Load the EDI document using the LoadEdi method of the ediDocument object. This method will read the EDI file, and verify its correctness using the implementation guideline in the standard reference library. FREDI will select an implementation guideline in the library that is specified in the EDI document. If the exact specification is not available in the standard reference library, FREDI will determine the best implementation guideline to use. The data is stored and organized internally in a hierarchical tree.
' Load EDI document normally.
oEdiDoc.LoadEdi App.Path & "\SampleEdiX12_850.X12"
Traverse data segments. The data segments of the EDI file that has been read using the LoadEdi method are stored internally and are organized in a hierarchical tree. The hierarchical relationship between the semantic objects are defined in an implementation guideline in the standard reference library, and the data segments are organized in this same hierarchical relationship. To traverse the data segments, access the first data segment in the tree using the FirstDataSegment of the ediDocument, and moving down the tree accessing subsequent data segments using NextDataSegment.
' Traverse all the data segments in the EDI document and extract the value in the its individual
' data elements.
Set oDataSegment = oEdiDoc.FirstDataSegment
While Not oDataSegment Is Nothing
Dim oDataElements As Fredi.ediDataElementsWend
Dim oDataElement As Fredi.ediDataElement
sDisplayString = sDisplayString & "Segment: " & oDataSegment.ID & vbCrLf
' Get the data elements collection of the data segment.
Set oDataElements = oDataSegment.DataElements
' Get the value of the individual data elements
For Each oDataElement In oDataElements
' Only show data elements that have dataNext
If Len(oDataElement.Value) > 0 Then
sDisplayString = sDisplayString & vbTab & "Element: " & oDataElement.ID & " = " & oDataElement.Value & vbCrLfEnd If
' Get the next data segment in the document.
Set oDataSegment = oEdiDoc.NextDataSegment
Sample program to translate ASC/X12 EDI file without any SEF
See Also: