All elements in the X12 standard can be marked as mandatory (M), optional (O), or Conditional (C or X). If an element is marked as conditional, its usage depends on the presence (or absence) of other elements in the same segment. These relational conditions are described using a specific X12 syntax and are usually found in the implementation guide shared between trading partners. While relational conditions were touched on briefly in Element Requirements in X12 EDI, this article provides a more in-depth analysis of the subject.

Overview

If an element is marked as conditional, that condition is governed by the associated syntax rule. Every syntax rule begins with an identifier: P, R, E, C, or L. Each identifier is then followed by two or more elements involved in the condition, where each element is referred to by its position in the segment (e.g., 01, 05, 11), and each element position occupies two digits. For a given segment, there can be one or more syntax rules, and a single element can be associated with one or more syntax rules inside a single segment.

The table below describes the meaning of each rule:

LetterNameConditionExample
PPairedIf the first element is present, then all the other elements must be present.P0102
RRequiredAt least one of the elements must be present.R020304
EExclusiveOnly one of the elements may be present.E0305
CConditionalIf the first element is present, then all the other elements must be present.C0102
LList conditionalIf the first element is present, then at least one of the other elements must be present.L010308

Paired (P)

If a syntax rule starts with P, it is a paired condition. This condition means that if any element in the rule is present in the segment, then all the other element(s) in the rule must be present as well.

A typical example of when a paired syntax rule is used is when one element describes the meaning of another. For example, elements N103 (Identification Code Qualifier) and N104 (Identification Code) are always paired, which is indicated by the syntax rule P0304. This means that if one of them is present, then the other must be present as well.

These two elements are paired because only sending one element would not make sense without the other. In this example, the N103 “qualifies” the N104 – it explains who or what entity assigned the identification code. Providing just the qualifier or just the identification code does not provide a trading partner with enough information, so they must be sent together.

The description of the paired syntax rule always follows this format:

  • If either {XX}, {YY},…, or {ZZ} is present, then the other is required.

Required (R)

If a syntax rule starts with R, it is a required condition. This condition means that at least one of the elements listed in the rule must be present in the segment. Typically, a required syntax rule is used when there are multiple positions within a segment to provide the necessary information, but not all elements are needed to communicate that information.

A good example of a required syntax rule is in the TXI (Tax Information) segment. This segment contains the R020306 syntax rule, which indicates that at least one of TXI02 (Monetary Amount), TXI03 (Percent), or TXI06 (Tax Exempt Code) is required. This means that you can provide the tax amount (e.g., $18.65), the tax percent (e.g., 12%), the code that explains tax exemption (e.g., F, Exempt from Goods and Services Tax), or all three - but you have to supply at least one, otherwise it will not convey enough information.

The description of the required syntax rule always follows this format:

  • At least one of {XX}, {YY},…, or {ZZ} is required.

Exclusive (E)

If a syntax rule starts with E, it is an exclusive condition. Only one of the elements in the syntax rule may be present, but no others.

Typically, an exclusive syntax rule is used when there are multiple elements in a segment that, if sent together, would cause a conflict in interpretation. A good example of an exclusive syntax rule is in the G72 (Allowance or Charge) segment. This segment contains a G7205 (Allowance or Charge Rate), a G7208 (Allowance or Charge Total Amount), and a G7209 (Allowance or Charge Percent). Because an allowance or charge can only be indicated as a unit rate, a total amount, or a percent (but not as more than one), these elements cannot be sent together.

The description of the exclusive syntax rule always follows this format:

  • Only one of {X}, {Y},…, or {Z} may be present.

Conditional (C)

If a syntax rule starts with C, it is a conditional rule. If the first element listed in the rule is present, then the subsequent elements must be present as well.

Typically, conditional rules are used because the first element listed in the rule cannot stand on its own; It is only useful when the subsequent elements are present. An example of a conditional rule is when there are two elements in the rule, and the first element listed provides added context to the second element. This is different from a paired syntax rule because the second element listed could stand on its own without the first element, whereas the first cannot.

For example, the DTM (Date/Time Reference) segment has a C0403 syntax rule. This rule states that if the DTM04 (Time Code) is present then the DTM03 (Time) is required. A time code in this case is synonymous with “time zone” (e.g., PT, ET, IST, etc.). As such, if the time code is present, but no time is present, then the time code is useless. However, if the DTM03 (Time) is present, then the time code is not necessarily required (but in this case, could be ambiguous).

The description of the conditional syntax rule always follows this format:

  • If {X} is present, then {Y} is required.

List conditional (L)

If a syntax rule starts with L, it is a list conditional rule. If the first element in the rule is present, then at least one of the other elements listed in the rule is required. There must always be three or more elements in a list conditional rule, otherwise, a conditional syntax rule should be used.

Typically, list conditional rules are used because the first element cannot stand on its own, and there are multiple other elements in the segment that can be used to provide the necessary information. For example, the ITD (Terms of Sale/Deferred Terms of Sale) segment contains the L03040513 rule. This means that if the ITD03 (Terms Discount Percent) is present, then at least one of ITD04 (Terms Discount Due Date), ITD05 (Terms Discount Days Due), or ITD13 (Day of Month) is required.

Because the terms discount percent given in the ITD03 needs an associated date, then one of the terms (i.e., discount due date, the terms discount days due, or the day of the month) is required in order to convey the information necessary to the recipient. As with conditional rules, the presence of ITD04, ITD05, or ITD13 does not make ITD03 required.

The description of the conditional syntax rule always follows this format:

  • If {X} is present, then at least one of {Y},…, or {Z} is required.