private void button1_Click(object sender, System.EventArgs e)
        {
            //This is just an example program to demonstrate how to acknowledge and create a CONTRL file in C#
            //using the Framework EDI hybrid component

            ediDocument oEdiDoc = null;
            ediAcknowledgment oAck = null;
            ediSchemas oSchemas = null;
            ediDataSegment oSegment = null;

            string sPath = AppDomain.CurrentDomain.BaseDirectory;
            string sEdiFile = "INVOIC.TXT";
            string sAckFile = "INVOIC_CONTRL.TXT";
            string sSefFileAck = "CONTRL.SEF";
            string sSefFileInvoic = "INVOIC_S93A.SEF";

 
            Cursor = Cursors.WaitCursor ;

            //CREATES EDIDOC OBJECT
            ediDocument.Set(ref oEdiDoc, new ediDocument());
 
            //If EDIFACT EDI file does not have a UNA segment, the terminators below will be used
            //GETS TERMINATORS
            oEdiDoc.SegmentTerminator = "'";
            oEdiDoc.ElementTerminator = "+";
            oEdiDoc.CompositeTerminator = ":";
            oEdiDoc.ReleaseIndicator = "?";
 
            //THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES 
            //NOT USE ITS BUILT-IN STANDARD REFERENCE TABLE TO VALIDATE THE EDI FILE.
            //THE VERSION OF THE EDI FILE MUST ALSO MATCH THE VERSION THAT THE SEF FILE SUPPORTS
            //OTHERWISE IT WILL STOP THE PROGRAM
            ediSchemas.Set(ref oSchemas,(ediSchemas) oEdiDoc.GetSchemas());  //oSchemas = (ediSchemas) oEdiDoc.GetSchemas();
            oSchemas.EnableStandardReference = false;
            //oSchemas.set_Option(SchemasOptionIDConstants.OptSchemas_VersionRestrict,1);
 
            //BECAUSE THE STANDARD REFERENCE HAS BEED DISABLED. 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(sPath + sSefFileAck, 0);
            oEdiDoc.LoadSchema(sPath + sSefFileInvoic, 0);
 
            //THIS OPTIONS STOPS FREDI FROM LOADING ALL OF THE SEGMENTS IN THE EDI FILE INTO MEMORY. 
            oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly;
 
            //CREATES THE ACKNOWLEDGMENT OBJECT
            oAck = (ediAcknowledgment) oEdiDoc.GetAcknowledgment();
 
            //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(sPath + sEdiFile);
 
            //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)
            ediDataSegment.Set(ref oSegment, (ediDataSegment) oEdiDoc.FirstDataSegment);  //oSegment = (ediDataSegment) oEdiDoc.FirstDataSegment;
            while ( oSegment != null )
            {
                ediDataSegment.Set(ref oSegment, (ediDataSegment) oSegment.Next());  //oSegment = (ediDataSegment) oSegment.Next();
            }
 
            //WRITES THE ACKNOWLEDGMENT INTO A FILE.
            oAck.Save(sPath + sAckFile);
 
            Cursor = Cursors.Default;

            MessageBox.Show("Done. Output = " + sPath + sAckFile);
        
        }
    }
    

    Click here to download a trial version of the Framework EDI