X12 824 Application Advice

The 824 is the X12 application advice. It reports the result of processing a previously received transaction in the receiver's application - for example an invoice rejected because a price does not match the order.

Each OTI loop identifies the original transaction and says whether it was accepted, accepted with errors, or rejected; TED segments describe each error.

At a glance

Standard
X12
Version
004010
Functional group
AG (GS01)
Sent by
Receiver of any transaction back to its sender
Responses
997
ediFabric .NET template
TS824 in EdiFabric.Templates.X12
OpenEDI definition
View 824 in the spec library

824 structure

The full X12 824 layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 5 loops and 22 segment positions, in file order. Loops are shaded and their segments indented; Max use is how many times a segment or loop may repeat.

Segment / loop Name Usage Max use
STTransaction Set HeaderMandatory1
BGNBeginning SegmentMandatory1
N1 loopNameOptional>1
N1NameMandatory1
N2Additional Name InformationOptional2
N3Address InformationOptional2
N4Geographic LocationOptional1
REFReference IdentificationOptional12
PERAdministrative Communications ContactOptional3
OTI loopOriginal Transaction IdentificationMandatory>1
OTIOriginal Transaction IdentificationMandatory1
REFReference IdentificationOptional12
DTMDate/Time ReferenceOptional2
PERAdministrative Communications ContactOptional3
AMTMonetary AmountOptional>1
QTYQuantityOptional>1
NM1Individual or Organizational NameOptional9
TED loopTechnical Error DescriptionOptional>1
TEDTechnical Error DescriptionMandatory1
NTENote/Special InstructionOptional100
REDRelated DataOptional100
LM loopCode Source InformationOptional>1
LMCode Source InformationMandatory1
LQ loopIndustry CodeMandatory100
LQIndustry CodeMandatory1
REDRelated DataOptional100
SETransaction Set TrailerMandatory1

Mandatory segments must be sent, Optional ones only when the data applies. Trading partners often add their own rules in companion guides - ediFabric templates can be adjusted to match. Open the element-level definition in the EdiNation spec library.

Sample 824 file

An application advice that reports errors in a received transaction. Paste it into EdiNation to see every element named and validated.

ISA*00*          *00*          *16*SENDER1        *14*RECEIVER1      *071216*1406*U*00204*000000263*1*T*>~
GS*IN*SENDER1*RECEIVER1*20071216*1406*000000001*X*004010~
ST*824*0002~
BGN*11*3*120902*1621~
N1*SU**92*42332AB~
N1*SF**92*42332A~
N1*ST**92*04025~
N1*MA**92*04025~
N1*CS**92*01123~
OTI*IR*SI*62001*******856~
REF*BM*62001~
REF*PK*87115~
REF*CN*506013~
REF*TB*01178~
REF*PM*05440113AA~
DTM*009*120901*1621*ET~
DTM*011*120901~
TED*201*ASN-PART/PLANT/SUPLR*****05440113AA0622137052~
NTE*LIN*INVALID PART/PLANT SUPPLIER COMBINATIO~
SE*18*0002~
GE*2*000000001~
IEA*1*000000263~

The same 824 as JSON

ediFabric turns every loop, segment and element into a named field. This is the transaction from the sample, in the JSON that ediFabric Native and Cloud return and accept.

{
  "ST": {
    "TransactionSetIdentifierCode_01": "824",
    "TransactionSetControlNumber_02": "0002"
  },
  "BGN": {
    "TransactionSetPurposeCode_01": "11",
    "ReferenceIdentification_02": "3",
    "Date_03": "120902",
    "Time_04": "1621"
  },
  "N1Loop": [
    {
      "N1": {
        "EntityIdentifierCode_01": "SU",
        "IdentificationCodeQualifier_03": "92",
        "IdentificationCode_04": "42332AB"
      }
    },
    {
      "N1": {
        "EntityIdentifierCode_01": "SF",
        "IdentificationCodeQualifier_03": "92",
        "IdentificationCode_04": "42332A"
      }
    },
    {
      "N1": {
        "EntityIdentifierCode_01": "ST",
        "IdentificationCodeQualifier_03": "92",
        "IdentificationCode_04": "04025"
      }
    },
    {
      "N1": {
        "EntityIdentifierCode_01": "MA",
        "IdentificationCodeQualifier_03": "92",
        "IdentificationCode_04": "04025"
      }
    },
    {
      "N1": {
        "EntityIdentifierCode_01": "CS",
        "IdentificationCodeQualifier_03": "92",
        "IdentificationCode_04": "01123"
      }
    }
  ],
  "OTILoop": [
    {
      "OTI": {
        "ApplicationAcknowledgmentCode_01": "IR",
        "ReferenceIdentificationQualifier_02": "SI",
        "ReferenceIdentification_03": "62001",
        "TransactionSetIdentifierCode_10": "856"
      },
      "REF": [
        {
          "ReferenceIdentificationQualifier_01": "BM",
          "ReferenceIdentification_02": "62001"
        },
        {
          "ReferenceIdentificationQualifier_01": "PK",
          "ReferenceIdentification_02": "87115"
        },
        {
          "ReferenceIdentificationQualifier_01": "CN",
          "ReferenceIdentification_02": "506013"
        },
        {
          "ReferenceIdentificationQualifier_01": "TB",
          "ReferenceIdentification_02": "01178"
        },
        {
          "ReferenceIdentificationQualifier_01": "PM",
          "ReferenceIdentification_02": "05440113AA"
        }
      ],
      "DTM": [
        {
          "DateTimeQualifier_01": "009",
          "Date_02": "120901",
          "Time_03": "1621",
          "TimeCode_04": "ET"
        },
        {
          "DateTimeQualifier_01": "011",
          "Date_02": "120901"
        }
      ],
      "TEDLoop": [
        {
          "TED": {
            "ApplicationErrorConditionCode_01": "201",
            "FreeFormMessage_02": "ASN-PART/PLANT/SUPLR",
            "CopyofBadDataElement_07": "05440113AA0622137052"
          },
          "NTE": [
            {
              "NoteReferenceCode_01": "LIN",
              "Description_02": "INVALID PART/PLANT SUPPLIER COMBINATIO"
            }
          ]
        }
      ]
    }
  ],
  "SE": {
    "NumberofIncludedSegments_01": "18",
    "TransactionSetControlNumber_02": "0002"
  }
}

Parse and validate an 824 file

Read the file into typed objects with ediFabric .NET, convert it to JSON in process with the ediFabric Native bindings for Python, Java and C, or post it to the ediFabric Cloud REST API from any language.

using EdiFabric.Templates.X12004010;

License.SetSerial("YOUR_SERIAL_KEY");

using (var stream = File.OpenRead(@"C:\edi\ApplicationAdvice.txt"))
using (var reader = new X12Reader(stream, "EdiFabric.Templates.X12"))
{
    var items = await reader.ReadToEndAsync();
    foreach (var transaction in items.OfType<TS824>())
    {
        if (transaction.IsValid(out MessageErrorContext errors))
            Console.WriteLine($"{transaction.ST.TransactionSetControlNumber_02} is valid");
        else
            Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten()));
    }
}
import json
import edifabric_x12 as ef

serial = "YOUR_SERIAL_KEY"
ef.load_library()
ef.set_serial(serial)
ef.set_map(json.dumps({"default": serial, "maps": {}}))

edi = open("ApplicationAdvice.txt", "rb").read()
output, offset = ef.parse(edi, ef.ParseMode.JSON_VALIDATE)
transactions = output[:offset]
report = json.loads(output[offset:])
print(report["errors_count"])
import com.edifabric.nativex12.EdiFabricX12;
import com.edifabric.nativex12.ParseMode;
import com.edifabric.nativex12.ParseResult;

String serial = "YOUR_SERIAL_KEY";
EdiFabricX12.loadLibrary();
EdiFabricX12.setSerial(serial);
EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}");

String edi = Files.readString(Path.of("ApplicationAdvice.txt"));
ParseResult result = EdiFabricX12.parse(edi, ParseMode.JSON_VALIDATE);
System.out.println(result.getTransactions());
System.out.println(result.getReport());
#include "edifabric_x12.h"

const char *serial = "YOUR_SERIAL_KEY";
ef_parse_result result;

if (ef_load_library(NULL) != 0)
    return 1;
ef_set_serial(serial);
ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}");

char *edi = read_file("ApplicationAdvice.txt", NULL);   /* helper in example_all_functions.c */
if (ef_parse(edi, EF_PARSE_JSON_VALIDATE, NULL, &result) == 0) {
    /* transactions = output[0 .. offset), report = output[offset .. length) */
    fwrite(result.output.data, 1, (size_t)result.output.length, stdout);
    ef_free(result.output.data);
}
curl -X POST 'https://api.edination.com/v2/x12/read' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@ApplicationAdvice.txt'

Generate an 824 file

Populate a TS824 object in .NET, or pass JSON in the shape shown above to ediFabric Native or ediFabric Cloud, and get a valid 824 file back.

using EdiFabric.Templates.X12004010;

License.SetSerial("YOUR_SERIAL_KEY");

var transaction = new TS824();

//  Transaction Set Identifier Code
//  = “824” (Application Acknowlegment Advice)
//  Transaction Set Control Number = 0002
transaction.ST = new ST();
transaction.ST.TransactionSetIdentifierCode_01 = "824";
transaction.ST.TransactionSetControlNumber_02 = "0001";

//  Transaction Set Purpose Code
//  = “11” (Response)
//  Reference Number = 3
//  Date = 09 / 02 / 2012
//  Time = 4:21 PM
transaction.BGN = new BGN();
transaction.BGN.TransactionSetPurposeCode_01 = "11";
transaction.BGN.ReferenceIdentification_02 = "3";
transaction.BGN.Date_03 = "120902";
transaction.BGN.Time_04 = "1621";

//  Repeating N1 Loops
transaction.N1Loop = new List<Loop_N1_824>();

// ... set the remaining loops and segments the same way

// SegmentBuilders is in the Common project of the example repository
using (var stream = new MemoryStream())
{
    using (var writer = new X12Writer(stream))
    {
        writer.Write(SegmentBuilders.BuildIsa("1"));
        writer.Write(SegmentBuilders.BuildGs("1"));
        writer.Write(transaction);
    }
    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
}
import json
import edifabric_x12 as ef

serial = "YOUR_SERIAL_KEY"
ef.load_library()
ef.set_serial(serial)
ef.set_map(json.dumps({"default": serial, "maps": {}}))

# the transactions JSON returned by ef.parse, edited or produced by your application
transactions = open("ApplicationAdvice.json", "rb").read()
edi = ef.build(transactions, postfix="\r\n")
print(edi)
import com.edifabric.nativex12.EdiFabricX12;

String serial = "YOUR_SERIAL_KEY";
EdiFabricX12.loadLibrary();
EdiFabricX12.setSerial(serial);
EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}");

// the transactions JSON returned by parse, edited or produced by your application
String transactions = Files.readString(Path.of("ApplicationAdvice.json"));
String edi = EdiFabricX12.build(transactions, "\r\n");
System.out.println(edi);
#include "edifabric_x12.h"

ef_buffer edi;

if (ef_load_library(NULL) != 0)
    return 1;
ef_set_serial("YOUR_SERIAL_KEY");
ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}");

/* the transactions JSON returned by ef_parse, edited or produced by your application */
char *transactions = read_file("ApplicationAdvice.json", NULL);
if (ef_build(transactions, "\r\n", &edi) == 0) {
    fwrite(edi.data, 1, (size_t)edi.length, stdout);
    ef_free(edi.data);
}
# the JSON returned by /read, edited or produced by your application
curl -X POST 'https://api.edination.com/v2/x12/write' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/json' \
--data-binary '@ApplicationAdvice.json' \
-o 'ApplicationAdvice.txt'

824 questions

How is the 824 different from the 997?

The 997 reports syntax errors found when the file is received. The 824 reports business or application errors found when the data is processed.

What do the OTI01 codes mean?

TA transaction set accept, TE accept with error, TR reject. OTI02 and OTI03 point to the original document, such as an invoice number.

Which transactions can an 824 respond to?

Any of them. It is most common for 810 invoices, 856 ship notices and 820 payment orders.

How do I parse and generate X12 824 files in .NET, Python, Java and C?

In .NET, install EdiFabric and EdiFabric.Templates.X12, read the file with X12Reader into TS824 objects and write them back with X12Writer. From Python, Java or C, use ediFabric Native, which converts 824 files to JSON and JSON back to X12 inside your process. From any other language, post the file to the ediFabric Cloud REST API.

Parse your first 824 in five minutes

The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud.