* CREATES EDIDOC OBJECT oEdiDoc = createobject("fredi.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. oSchemas = oEdiDoc.GetSchemas oSchemas.EnableStandardReference = .F. * THIS OPTIONS STOPS FREDI FROM KEEPING ALL THE SEGMENTS IN MEMORY oEdiDoc.CursorType = 1 * GETS TERMINATORS oEdiDoc.SegmentTerminator = "'" oEdiDoc.ElementTerminator = "+" oEdiDoc.CompositeTerminator = ":" oEdiDoc.ReleaseIndicator = "?" * LOADS THE SEF FILE oEdiDoc.LoadSchema("ORDERS_D96A.SEF", 0) * LOADS THE EDI FILE oEdiDoc.LoadEdi("ORDERS_D96A.EDI") * GETS THE FIRST DATA SEGMENT oSegment = oEdiDoc.FirstDataSegment * LOOP THAT WILL TRAVERSE THRU EDI FILE FROM TOP TO BOTTOM do while !isnull(oSegment) * DATA SEGMENTS WILL BE IDENTIFIED BY THEIR ID, THE LOOP SECTION AND AREA * (OR TABLE) NUMBER THAT THEY ARE IN. sSegmentID = oSegment.ID sLoopID = oSegment.LoopSection nArea = oSegment.Area do case case nArea = 0 do case case sLoopID == "" do case case sSegmentID = "UNB" sValue = oSegment.DataElementValue(1,1) && Syntax identifier sValue = oSegment.DataElementValue(1,2) && Syntax version number 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(3,1) && Recipient identification sValue = oSegment.DataElementValue(3,2) && Partner identification code qualifier sValue = oSegment.DataElementValue(3,3) && Routing address sValue = oSegment.DataElementValue(4,1) && Date sValue = oSegment.DataElementValue(4,2) && Time sValue = oSegment.DataElementValue(5) && Interchange control reference endcase && sSegmentID endcase && sLoopID case nArea = 1 do case case sLoopID == "" do case case sSegmentID = "UNH" sValue = 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 case sSegmentID = "BGM" 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 sValue = oSegment.DataElementValue(2) && Document/message number sValue = oSegment.DataElementValue(3) && Message function, coded case sSegmentID = "DTM" sValue = oSegment.DataElementValue(1,1) && Date/time/period qualifier sValue = oSegment.DataElementValue(1,2) && Date/time/period sValue = oSegment.DataElementValue(1,3) && Date/time/period format qualifier endcase && sSegmentID case sLoopID == "RFF" do case case sSegmentID = "RFF" sValue = oSegment.DataElementValue(1,1) && Reference qualifier sValue = oSegment.DataElementValue(1,2) && Reference number sValue = oSegment.DataElementValue(1,3) && Line number sValue = oSegment.DataElementValue(1,4) && Reference version number endcase && sSegmentID case sLoopID == "NAD" do case case sSegmentID = "NAD" sValue = oSegment.DataElementValue(1) && Party qualifier sValue = oSegment.DataElementValue(2,1) && Party identification sValue = oSegment.DataElementValue(2,2) && Code list qualifier sValue = oSegment.DataElementValue(2,3) && Code list responsible agency, coded endcase && sSegmentID case sLoopID == "TDT" do case case sSegmentID = "TDT" 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 endcase && sSegmentID case sLoopID == "TDT;LOC" do case case sSegmentID = "LOC" 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 endcase && sSegmentID endcase && sLoopID case nArea = 2 do case case sLoopID == "LIN" do case case sSegmentID = "LIN" sValue = oSegment.DataElementValue(1) && Line item number endcase && sSegmentID case sLoopID == "LIN;LOC" do case case sSegmentID = "LOC" sValue = oSegment.DataElementValue(1) && Place/location qualifier case sSegmentID = "QTY" sValue = oSegment.DataElementValue(1,1) && Quantity qualifier sValue = oSegment.DataElementValue(1,2) && Quantity sValue = oSegment.DataElementValue(1,3) && Measure unit qualifier case sSegmentID = "DTM" sValue = oSegment.DataElementValue(1,1) && Date/time/period qualifier sValue = oSegment.DataElementValue(1,2) && Date/time/period sValue = oSegment.DataElementValue(1,3) && Date/time/period format qualifier endcase && sSegmentID case sLoopID == "LIN;NAD" do case case sSegmentID = "NAD" sValue = oSegment.DataElementValue(1) && Party qualifier sValue = oSegment.DataElementValue(2,1) && Party identification sValue = oSegment.DataElementValue(2,2) && Code list qualifier sValue = oSegment.DataElementValue(2,3) && Code list responsible agency, coded endcase && sSegmentID endcase && sLoopID case nArea = 3 do case case sLoopID == "" do case case sSegmentID = "UNS" sValue = oSegment.DataElementValue(1) && Section identification endcase && sSegmentID endcase && sLoopID endcase && nArea * GETS THE NEXT DATA SEGMENT oSegment = oSegment.Next enddo