var oEdiDoc: IediDocument; oAck: IediAcknowledgment; oSchema: IediSchema; oSchemas: IediSchemas; oSegment: IediDataSegment; sSegmentID: String; begin // CREATES OEDIDOC OBJECT oEdidoc := coedidocument.Create; // SETS 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 as IediAcknowledgment; // ENABLES THE CREATION OF THE FUNCTIONAL ACKNOWLEDGMENT WHEN FREDI LOADS AN EDI FILE. oAck.EnableFunctionalAcknowledgment := True; // 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 as IediDataSegment; While oSegment <> Nil do begin oSegment := oSegment.Next as IediDataSegment; End; // 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 as IediDataSegment; // oSegment := oSegment.GetDataSegmentByPos('\UNB\UNH\UNC') as IediDataSegment; // if oSegment.DataElementValue[3] = "7" then begin // end; // WRITES THE ACKNOWLEDGMENT INTO A FILE. oAck.Save('ORDERS_D96A.ACK.EDI'); end;