Framework EDI Reference. Methods and Properties
ediDataElement. RecordAckCode

Record an error code in an acknowledgment document for the data element.

Syntax:

Parameters:

Returns:

Returns 1 if the acknowledgment code was recorded successfully; otherwise 0 is returned.

Remarks:

This method is used when reading a document in Cursor_ForwardOnly, where the EDI document is traversed, and validated, a data segment at a time.  The data elements for each of the data segment can then be accessed at which point this method can be called for any of the data element.  Note that the acknowledgment code that is to be recorded must be pertinent to the data element from where this method is called because other properties of the data element (e.g. element value) may also be recorded in the acknowledgment document together with the acknowledgment code.  For example in ASC/X12,  take the Data Element Note (AK4) data stream in an acknowledgment after the method RecordAckCode("X") is called

AK4!2!309!X!abc

(The segment ID is "AK4" and "X" is the acknowledgment code.) The data element properties are:

Example:

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

oEdiDoc = new ediDocument();

oAck = oEdiDoc.GetAcknowledgment();
oAck.EnableFunctionalAcknowledgment = true;

oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly;

oEdiDoc.LoadSchema(sCodePath + "\\SampleSefX12_850.SEF", SchemaTypeIDConstants.Schema_Standard_Exchange_Format);
oEdiDoc.LoadEdi(sCodePath + "\\SampleEdiX12_850.X12");

//iterate through each segment in the the EDI file so that they can be validated
ediDataSegment.Set(ref oSegment, oEdiDoc.FirstDataSegment);
while (oSegment != null)
{
    String sSegmentID = oSegment.ID;
    if (sSegmentID == "FOB")
    {
        ediDataElement oElement = null;
        for (int i = 1; i <= oSegment.Count; i++)
        {
            ediDataElement.Set(ref oElement, oSegment.GetDataElementByPos(i));
            String sValue = oElement.Value;

            if (oElement.ID == "309")
            {
                oElement.RecodeAckValue("X");
            }
        }
    }

    ediDataSegment.Set(ref oSegment, oSegment.Next());
}