//This is just an example program to demonstrate how to create a 999 Implementation Acknowledgment
            //in C# using the Framework EDI component.

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

            string sSegmentID;
            string sLoopSection;
            int nArea;

            string sPath = AppDomain.CurrentDomain.BaseDirectory;

            //edi file to be acknowledged
            //string sEdiFile = "837_5010X222A1.X12";
            string sEdiFile = "837_5010X222A1_bad.X12";

            Cursor = Cursors.WaitCursor;

            //instantiat edi document object
            ediDocument.Set(ref oEdiDoc, new ediDocument());    // oEdiDoc = new ediDocument();

            //By default, FREDI uses the  universal coordinated time (UTC), however you can change it to local time

            // Disabling the internal standard reference library to makes sure that 
            // FREDI uses only the SEF file provided
            ediSchemas.Set(ref oSchemas,(ediSchemas) oEdiDoc.GetSchemas());    //oSchemas = (ediSchemas) oEdiDoc.GetSchemas();
            oSchemas.EnableStandardReference = false;

            // This makes certain that the EDI file must use the same version SEF file, otherwise
            // the process will stop.

            // By setting the cursor type to ForwardOnly, FREDI does not load the entire file into memory, which
            // improves performance when processing larger EDI files.
            oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly;

            // If an acknowledgment file has to be generated, an acknowledgment object must be created, and its 
            // property must be enabled before loading the EDI file.
            oAck = (ediAcknowledgment) oEdiDoc.GetAcknowledgment();
            oAck.EnableImplementationAcknowledgment = true;

            //Property to enable TA1 acknowledgment in the 999
            oAck.EnableInterchangeAcknowledgment = true;
            //Option to combine the TA1 and 997 into one Interchange
            oAck.set_Option(AcknowledgmentOptionIDConstants.OptAcknowledgment_Combine, 1);

            //Accept transaction set with errors
            //oAck.AcceptSetWithErrors = true;    //IK501 code will be "E" if transaction set has errors, and accepted.

            // Set the starting point of the control numbers in the acknowledgment

            // Error codes that are not automatically mapped to an acknowlegment error number by FREDI can be set by
            // using the MapDataElementLevelError method.
            oAck.MapDataElementLevelError(13209, 5,"","","","");

            // All SEF files required for processing the EDI files must be provided by calling the LoadSchema.  
            // The "LoadSchema" method does not actually load the SEF files at this time, but are actually 
            // loaded during the LoadEdi method.
            oEdiDoc.LoadSchema(sPath + "999_005010X231A1.EVAL0.SEF", 0);    // evaluation SEF file for Ack (999) file
            oEdiDoc.LoadSchema(sPath + "837_005010X222A1.SemRef.EVAL0.SEF", 0);    // evaluation SEF file for EDI (837) file

            // Loads EDI file and the corresponding SEF file
            oEdiDoc.LoadEdi(sPath + sEdiFile);

            // Gets the first data segment in the EDI files
            ediDataSegment.Set(ref oSegment, (ediDataSegment) oEdiDoc.FirstDataSegment);  //oSegment = (ediDataSegment) oEdiDoc.FirstDataSegment

            //Iterate through all segments in the EDI fle so that component has a chance to validate them.
            while ( oSegment != null ) 
                //get next data segment
                ediDataSegment.Set(ref oSegment, (ediDataSegment) oSegment.Next());    //oSegment = (ediDataSegment) oSegment.Next();

            // Checks the 999 acknowledgment file just created.  It can also be modified at this time.
            // The 999 file is an EDI file, so the logic to read the 999 Implementation Acknowledgemnt file is similar
            // to translating any other EDI file.

            // Gets the first segment of the 997 acknowledgment file
            ediDataSegment.Set(ref oSegment, (ediDataSegment)oAck.GetFirstDataSegmentByAck("999"));    //oSegment = (ediDataSegment) oAck.GetFirstDataSegmentByAck("999");

            while ( oSegment != null ) 
                nArea = oSegment.Area;
                sLoopSection = oSegment.LoopSection;
                sSegmentID = oSegment.ID;

                if (nArea == 0)
                    if (sSegmentID == "TA1")
                        if (oSegment.get_DataElementValue(4, 0) == "A")
                            MessageBox.Show("Interchange Accepted");

                else if (nArea == 1)
                    if (sLoopSection == "")
                        if (sSegmentID == "ST")
                            oSegment.set_DataElementValue(3, 0, "005010X231A1"); //Add this value into data element ST03 because it is not automatically generated
                        else if (sSegmentID == "AK9")
                            if (oSegment.get_DataElementValue(1, 0) == "A")
                                MessageBox.Show("Funtional Group accepted");
                                //You can modify the 999 and overwrite FREDI's default value 
                                oSegment.set_DataElementValue(1, 0,"P"); //Partially accepted.  At least one transaction set was rejected.
                    }    // sLoopSection == ""
                    else if (sLoopSection == "AK2")
                        if (sSegmentID == "IK5")
                            if (oSegment.get_DataElementValue(1, 0) == "R")
                                MessageBox.Show("Transaction set rejected");

                }    //nArea == 1

                ediDataSegment.Set(ref oSegment, (ediDataSegment) oSegment.Next());    //oSegment = (ediDataSegment) oSegment.Next();
            }    //oSegment != null

            //save the 999 acknowledgment
            oAck.Save(sPath + "999_" + sEdiFile);

            //display ack
            MessageBox.Show(oAck.GetEdiString(),"999 Ack file");

            Cursor = Cursors.Default;

            MessageBox.Show("Done. Output = " + sPath + "999_" + sEdiFile);


    Click here to download a trial version of the Framework EDI