* CREATES EDIDOC OBJECT oEdiDoc = createobject("fredi.ediDocument") * GETS TERMINATORS oEdiDoc.SegmentTerminator = "'" oEdiDoc.ElementTerminator = "+" oEdiDoc.CompositeTerminator = ":" oEdiDoc.ReleaseIndicator = "?" * YOU MUST LOAD BOTH THE CONTRL SEF FILE (FOR FREDI TO CREATE AN EDI CONTRL FILE), * AS WELL AS THE SEF FILE THAT WILL BE USED TO VALIDATE THE EDI FILE. * PLEASE NOTE THAT YOU MUST LOAD THE CORRECT VERSION OF THE CONTRL SEF FILE. oEdiDoc.LoadSchema("CONTRL.SEF", 0) oEdiDoc.LoadSchema("ORDERS_D96A.SEF", 0) * THIS OPTIONS STOPS FREDI FROM LOADING ALL OF THE SEGMENTS IN THE EDI FILE INTO MEMORY. oEdiDoc.CursorType = 1 * CREATES THE ACKNOWLEDGMENT OBJECT oAck = oEdiDoc.GetAcknowledgment * ENABLES THE CREATION OF THE FUNCTIONAL ACKNOWLEDGMENT WHEN FREDI LOADS AN EDI FILE. oAck.EnableFunctionalAcknowledgment = 1 * LOADS THE EDI FILE. NOTE THAT WHEN THE CURSOR TYPE FORWARD IS ENABLED, ONLY THE FIRST * DATA SEGMENT IS LOADED; OTHERWISE THE WHOLE EDI FILE GETS LOADED INTO MEMORY oEdiDoc.LoadEdi("ORDERS_D96A.EDI") * IF THE CURSOR TYPE FORWARD IS ENABLED, YOU MUST TRAVERSE THRU THE WHOLE EDI FILE * SO THAT IT ALLOWS FREDI TO LOAD EACH SEGMENT AND ANALYZE THEM. (FREDI DOES NOT KEEP * THE SEGMENTS IN MEMORY, BUT DISCARDS THEM ONCE THEY HAVE BEEN READ) oSegment = oEdiDoc.FirstDataSegment Do While !isnull(oSegment) oSegment = oSegment.Next EndDo * ONCE THE WHOLE EDI FILE HAS BEEN READ, CAN YOU THEN MANAGE AND MANIPULATE DATA * OF THE ACK OBJECT THAT FREDI CREATED AUTOMATICALLY. * GETS THE FIRST DATA SEGMENT OF THE ACK OBJECT * oSegment = oAck.GetFirstContrlDataSegment * oSegment = oSegment.GetDataSegmentByPos("\UNB\UNH\UCM") * if oSegment.DataElementValue(3) = "7" then * endif * WRITES THE ACKNOWLEDGMENT INTO A FILE. oAck.Save("ORDERS_D96A.ACK.EDI")