X12 Logo

X12.6 Application Control Structure

JANUARY 2025

1. Purpose and Scope

This standard defines the structure of business transactions for computer-to-computer interchange. This structure is expressed using a symbolic representation of X12 data independent of the physical representation (e.g., character set encoding). Transformations that affect the physical representation of the data are outside the scope of this standard. The symbolic representation is expressed in terms of both the design and use of X12 structures. This includes the control segments used to bound loops of data segments, transaction sets, and groups of related transaction sets, and the special control segments used to bound transaction sets and groups of transaction sets for security purposes.

This standard does not define any specific transaction set. Data segments are defined in a segment directory; data elements are defined in a data element dictionary; composite data structures are defined in a composite data structure directory; control segments and the binary segment are defined in this standard and fully described in a segment directory.

2. Referenced and Related Standards

This standard is used with the ASC X12 series of standards on electronic data interchange.

The following material is from The Internet Engineering Task Force (IETF®). The mission of the IETF is to make the Internet work better by producing high quality, relevant technical documents that influence the way people design, use, and manage the Internet.

The following verbatim text is from the cited document as noted immediately below.

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <http://www.rfc-editor.org/info/rfc2119>.

Key words for use in RFCs to Indicate Requirement Levels

In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. Authors who follow these guidelines should incorporate this phrase near the beginning of their document:

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Note that the force of these words is modified by the requirement level of the document in which they are used.

  1. MUST   This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification.

  2. MUST NOT   This phrase, or the phrase "SHALL NOT", mean that the definition is an absolute prohibition of the specification.

  3. SHOULD   This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

  4. SHOULD NOT   This phrase, or the phrase "NOT RECOMMENDED", mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.

  5. MAY   This word, or the adjective "OPTIONAL", mean that an item is truly optional. One vendor may choose to include the item because a particular marketplace requires it or because the vendor feels that it enhances the product while another vendor may omit the same item. An implementation which does not include a particular option MUST be prepared to interoperate with another implementation which does include the option, though perhaps with reduced functionality. In the same vein an implementation which does include a particular option MUST be prepared to interoperate with another implementation which does not include the option (except, of course, for the feature the option provides.)

3. Definitions and Concepts

3.1 Basic Structure

The X12 standards define commonly used business transactions in a formal, structured manner called transaction sets. A transaction set is composed of a transaction set header control segment, one or more data segments, and a transaction set trailer control segment. Optionally the transaction set may also include a transaction security header control segment and transaction security trailer control segment when it is desirable to send the data within the transaction envelope in an authenticated or encrypted form, or both.

Each segment is composed of: a unique segment ID; one or more logically related simple data elements or composite data structures, or both, each preceded by a data element separator; and a segment terminator. Composite data structures are composed of one or more logically related component data elements, each, except the last, followed by a component element separator. The data segment directory entry referenced by the data segment identifier defines the sequence of simple data elements and composite data structures in the segment and any interdependencies that may exist. The composite data structure directory entry referenced by the composite data structure number defines the sequence of component data elements in the composite data structure.

A data element in the transaction set header identifies the type of transaction set. A functional group contains one or more related transaction sets preceded by a functional group header control segment and terminated by a functional group trailer control segment. Optionally, the functional group may also include a functional security header control segment and functional security trailer control segment when it is desirable to send the data within the functional envelope in an authenticated or encrypted form, or both.

3.2 Syntax Notation

The syntax is defined in a Backus-Naur Form (BNF), which is described in 3.2.1 through 3.2.8. Each definition is accompanied by explanatory text. In some cases actual use (the actual data stream) of an X12 structure may not be the same as the definition. These instances are caused by the optional nature of some structures. Where such structures occur in this document, two representations of the BNF are presented, labeled "definition" and "use" respectively.

3.2.1 Syntactic Entities

Lowercase strings that are enclosed in angle brackets denote syntactic entities. The underscore is included as a valid character for this representation. For example:

<transaction_set>

3.2.2 Defined Constructs

The defined construct is on the left side of a statement and is separated from the defining right side by two colons and an equal sign (::=). For example:

<one_construct>

::=

<another_construct>

3.2.3 Other Inclusions

In the statements, spaces between syntactic entities are not significant and may be included for clarity. Meaningful spaces may be included in the statements by enclosing them in quotation marks. Other symbols may be included in quotation marks for clarity. The right side of the statement may be continued onto lower lines and be divided between syntactical entities. Ellipses (...) are used to represent missing items when a logical progression has been established.

3.2.4 Alternative Definitions

When alternative definitions exist, they may be shown separated by a vertical bar (|). For example:

<letter_or_digit>

::=

<uppercase_letter> | <digit>

3.2.5 Predefined Labels

Certain character strings (for example, "ST") are predefined labels and are always to be used as they are given. Punctuation symbols appear as they would in the transfer of data; for example, the decimal point in "1.2" shall be specified as:

<digit> . <digit>

3.2.6 Optional Items

Square brackets enclose optional items. For example, the optional negative sign is expressed as:

[-]

3.2.7 Multiple Occurrences

Braces enclose an item which may appear zero or more times. For example:

<unsigned_integer>

::=

<digit> {digit}

3.2.8 Minimums/Maximums

The minimum and maximum number of characters that may be used for a syntactic entity is specified by the inclusion of two numbers in parentheses appended to the end of the syntactic construct as (minimum/maximum). This is used to represent the minimum and maximum lengths of a data element in the data element dictionary.

<id>(02/03)

::=

<letter_or_digit> <letter_or_digit> [<letter_or_digit>]

3.2.9 External Entities

Uppercase strings that are enclosed in angle brackets denote syntactic entities that are defined external to this document. When used they are accompanied by text specifying the entity or entities referenced. The underscore is included as a valid character for this representation. For example:

<ISO_LANGUAGE_CHARACTER>

3.3 Character Set

All data element values, except those of the binary data element, shall be constructed using the character set specified in 3.3.1 through 3.3.3. The character set of this standard is grouped according to common characteristics.

NOTE:
The X12 standards are graphic-character oriented, so any common character encoding schemes may be used as long as a common mapping is available. No collating sequence is to be assumed in any definition used in the standard since no single character code is specified and no other means of specifying a sequence is provided.

3.3.1 Basic Character Set

The basic character set of this standard consists of uppercase letters, digits, special characters, and space.

(1) Uppercase letters from A to Z:

<uppercase_letter>

::=

"A" | ... | "Z"

 

Latin Alphabet: Uppercase

A Latin Capital letter A
B Latin Capital letter B
C Latin Capital letter C
D Latin Capital letter D
E Latin Capital letter E
F Latin Capital letter F
G Latin Capital letter G
H Latin Capital letter H
I Latin Capital letter I
J Latin Capital letter J
K Latin Capital letter K
L Latin Capital letter L
M Latin Capital letter M
N Latin Capital letter N
O Latin Capital letter O
P Latin Capital letter P
Q Latin Capital letter Q
R Latin Capital letter R
S Latin Capital letter S
T Latin Capital letter T
U Latin Capital letter U
V Latin Capital letter V
W Latin Capital letter W
X Latin Capital letter X
Y Latin Capital letter Y
Z Latin Capital letter Z

(2) Digits from 0 to 9:

<digit>

::=

"0" | ... | "9"

 

ASCII Digits

0 Digit Zero
1 Digit One
2 Digit Two
3 Digit Three
4 Digit Four
5 Digit Five
6 Digit Six
7 Digit Seven
8 Digit Eight
9 Digit Nine

(3) Special characters:

<special_char>

::=

"!" | """ | "&" | "'" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | "?" | "="

 

ASCII Punctuation & Symbols

! Exclamation mark
" Quotation mark
& Ampersand
' Apostrophe
( Left parenthesis
) Right parenthesis
* Asterisk
+ Plus sign
, Comma
- Hyphen-minus
. Full stop
/ Slash (Solidus)
: Colon
; Semicolon
? Question mark
= Equal sign

NOTE:
Special characters are removed from this category when used as delimiters or release character, unless protected by the release character.

(4) The space character:

<space>

::=

" "

ASCII Punctuation & Symbols

  Space

3.3.2 Extended Character Set

An extended character set may be used by agreement between communicating parties and includes the lowercase letters, other special characters, national characters, and select language characters, and other language characters.

(1) Lowercase letters from a to z:

<lowercase_letter>

::=

"a" | ... | "z"

 

Latin Alphabet: Lowercase

a Latin Small letter A
b Latin Small letter B
c Latin Small letter C
d Latin Small letter D
e Latin Small letter E
f Latin Small letter F
g Latin Small letter G
h Latin Small letter H
i Latin Small letter I
j Latin Small letter J
k Latin Small letter K
l Latin Small letter L
m Latin Small letter M
n Latin Small letter N
o Latin Small letter O
p Latin Small letter P
q Latin Small letter Q
r Latin Small letter R
s Latin Small letter S
t Latin Small letter T
u Latin Small letter U
v Latin Small letter V
w Latin Small letter W
x Latin Small letter X
y Latin Small letter Y
z Latin Small letter Z

(2) Other special characters:

<other_special_char>

::=

"%" | "@" | "[" | "]" | "_" | "{" | "}" | "\" | "|" | "<" | ">" | "~" | "^" | "`"

 

ASCII Punctuation & Symbols

% Percent sign
@ At sign
[ Left Square Bracket
] Right Square Bracket
_ Low line (Underscore)
{ Left Curly Bracket
} Right Curly Bracket
\ Backslash
| Vertical bar
< Less-than sign
> Greater-than sign
~ Tilde
^ Circumflex accent
` Grave accent

NOTE:
Special characters are removed from this category when used as delimiters unless protected by the release character.

(3) National characters:

<national_char>

::=

"#" | "$"

 

Latin Alphabet: Lowercase

# Number sign
$ Dollar sign

(4) Select language characters:

<select_language_char>

::=

"À" | "Á" | "Â" | "Ä" | "Å" | "à" | "á" | "â" | "ä" | "ã" | "å" | "æ" | "È" | "É" | "Ê" | "è" | "é" | "ê" | "ë" | "Ì" | "Í" | "Î" | "ì" | "í" | "î" | "ï" | "Ò" | "Ó" | "Ô" | "Ö" | "ò" | "ó" | "ô" | "ö" | "Ù" | "Ú" | "Û" | "Ü" | "ù" | "ú" | "û" | "ü" | "Ç" | "ç" | "Ñ" | "ñ" | "¿" | "¡" | "Ø" | "ø"

 

Letters

À Latin Capital Letter A with grave
Á Latin Capital letter A with acute
 Latin Capital letter A with circumflex
Ä Latin Capital letter A with diaeresis
Å Latin Capital letter A with ring above
à Latin Small Letter A with grave
á Latin Small Letter A with acute
â Latin Small Letter A with circumflex
ä Latin Small Letter A with diaeresis
ã Latin Small Letter A with tilde
å Latin Small Letter A with ring above
æ Latin Small Letter Ae
È Latin Capital letter E with grave
É Latin Capital letter E with acute
Ê Latin Capital letter E with circumflex
è Latin Small Letter E with grave
é Latin Small Letter E with acute
ê Latin Small Letter E with circumflex
ë Latin Small Letter E with diaeresis
Ì Latin Capital letter I with grave
Í Latin Capital letter I with acute
Î Latin Capital letter I with circumflex
ì Latin Small Letter I with grave
í Latin Small Letter I with acute
î Latin Small Letter I with circumflex
ï Latin Small Letter I with diaeresis
Ò Latin Capital letter O with grave
Ó Latin Capital letter O with acute
Ô Latin Capital letter O with circumflex
Ö Latin Capital letter O with diaeresis
ò Latin Small Letter O with grave
ó Latin Small Letter O with acute
ô Latin Small Letter O with circumflex
ö Latin Small Letter O with diaeresis
Ù Latin Capital letter U with grave
Ú Latin Capital letter U with acute
Û Latin Capital Letter U with circumflex
Ü Latin Capital Letter U with diaeresis
ù Latin Small Letter U with grave
ú Latin Small Letter U with acute
û Latin Small Letter U with circumflex
ü Latin Small Letter U with diaeresis
Ç Latin Capital letter C with cedilla
ç Latin Small Letter C with cedilla
Ñ Latin Capital letter N with tilde
ñ Latin Small Letter N with tilde
¿ Inverted Question Mark
¡ Inverted Exclamation Mark
Ø Latin Capital letter O with stroke
ø Latin Small Letter O with stroke

NOTE:
See ISO document 8859-1 (Latin-1 Alphabet) for an example of an encoding of select language characters.

(5) Other language characters:

<ISO_LANGUAGE_CHARACTERS>

 

Any graphical character that is specified in any of the following ISO documents that is not defined in any of the previous BNF productions:

  • ISO 646

  • ISO 8859-1

  • ISO 8859-2

  • ISO 8859-5

  • ISO 8859-7

  • ISO 8859-3

  • ISO 8859-4

  • ISO 8859-6

  • ISO 8859-8

  • ISO 8859-9

  • ISO 8859-15

  • ISO 2022

  • ISO 2375

  • ISO 10646

3.3.3 Empty Character Set

An empty character set is the absence of data.

<Empty>

::=

""

3.4 Syntax Objects

Syntax Objects consist of four delimiters, and optionally, a release character.

3.4.1 Delimiters

The delimiters consist of three separators and a terminator. The delimiters are an integral part of the transferred data stream. Delimiters are specified in the interchange header and shall not be used in a data element value elsewhere in the interchange with the exceptions of their possible appearance in the binary data element or when protected by the release character.

The separators and terminator are:

<tr>

::=

segment terminator

<gs>

::=

data element separator

<us>

::=

component element separator

<rs>

::=

repetition separator

3.4.2 Release Character

When specified in the interchange control structure, the release character prevents the character immediately following its appearance from being treated as a Syntax Object.

3.5 Data Element

The data element is the smallest named unit of information in the standard. Data elements are identified as either simple or component. A data element that occurs as an ordinally positioned member of a composite data structure is identified as a component data element. A data element that occurs in a segment outside the defined boundaries of a composite data structure is identified as a simple data element. The distinction between simple and component data elements is strictly a matter of context since a data element can be used in either capacity. The following definitions apply equally to each class of data element.

<simple_data_element>

::=

<data_element>

<component_data_element>

::=

<data_element>

<data_element>

::=

<numeric> | <decimal_number> | <id> | <string> | <date> | <time> | <binary>

3.5.1 Data Element Types

The data element types and the length characteristics of each of these types are described in 3.5.1.1 through 3.5.2.3.

3.5.1.1 Numeric

A numeric is represented by one or more digits with an optional leading sign representing a value in the normal base of 10.

<numeric>

::=

[-] <unsigned_integer>

<unsigned_integer>

::=

<digit> {<digit>}

 

The value of a numeric data element includes an implied decimal point. It is used when the position of the decimal point within the data is permanently fixed and is not to be transmitted with the data. The data element dictionary defines the number of implied decimal positions. The representation for this data element type is Nn where "N" indicates that it is numeric and "n" indicates the number of decimal positions to the right of the implied decimal point. If n is 0, it need not appear in the specification; N is equivalent to N0. For negative values, the leading minus sign (-) is used. Absence of a sign indicates a positive value. The plus sign (+) shall not be transmitted. Leading zeros should be suppressed unless necessary to satisfy a minimum length requirement. The length of a numeric type data element does not include the optional sign.

FOR EXAMPLE:

Value is -123.4
Numeric type is N2 where the "2" indicates an implied decimal placement two positions from the right
The data stream value is -12340
The length is 5 (note padded zero)

3.5.1.2 Decimal Number

A decimal data element contains an explicit decimal point and is used for numeric values that have a varying number of decimal positions. The representation for this data element type is R. The decimal point always appears in the character stream if the decimal point is at any place other than the right end. If the value is an integer (decimal point at the right end) the decimal point should be omitted. For negative values, the leading minus sign (-) is used. Absence of a sign indicates a positive value. The plus sign (+) shall not be transmitted. Leading zeros shall be suppressed unless necessary to satisfy a minimum length requirement. Trailing zeros following the decimal point should be suppressed unless necessary to indicate precision. A base 10 exponential may be appended to the end of a decimal number. The absolute value of a decimal number with a base 10 exponential is equal to the value of the <unsigned_decimal_number> multiplied by 10 raised to the power of <exponent>. The use of triad separators (for example, the commas in "1,000,000") is expressly prohibited. The length of a decimal type data element does not include the optional minus signs, decimal point, or trailing exponent indicator "E".

<decimal_number>

::=

[-] <unsigned_decimal_number> [<base_10_exponential>]

<base_10_exponential>

::=

E <exponent>

<exponent>

::=

[-] <unsigned_integer>

<unsigned_decimal_number>

::=

<unsigned_integer> | .<unsigned_integer> | <unsigned_integer> . {<digit>}

 

EXAMPLE A:

Value is -123.45
Decimal type symbol is R
The data stream value is -123.45
The length is 5

EXAMPLE B:

Value is 12345
Decimal type symbol is R
The data stream value is 12345
The length is 5

EXAMPLE C:

Value is .1250
Decimal type symbol is R
The data stream value is 1250E-4
The length is 5

3.5.1.3 Identifier

An identifier data element always contains a unique value from a single, predefined list of values. That list of values is either enumerated within the data element in X12.3 Data Element Dictionary or the source of the list of values is specified in Appendix A in the X12.3 Data Element Dictionary. Trailing spaces should be suppressed. The representation for this data element type is ID.

<id>

::=

<letter_or_digit> {<letter_or_digit>} {<space>}

<letter_or_digit>

::=

<uppercase_letter> | <digit>

3.5.1.4 Identifier 2

An identifier 2 data element always contains a unique value from a single, predefined list of values. That list of values is either enumerated within the data element in X12.3 Data Element Dictionary or the source of the list of values is specified in Appendix A in the X12.3 Data Element Dictionary. Leading and trailing spaces are not permitted. The representation for this data element type is ID2.

<id2>

::=

<id2_character> | <id2x>

<id2x>

::=

<id2_character> {<id2_character> | <space>} <id2_character>

<id2_character>

::=

<uppercase_letter> | <digit> | <special_char> | <lowercase_letter> | <other_special_char> | <national_char> | <select_language_character> | <ISO_LANGUAGE_CHARACTER>

3.5.1.5 String

A string data element is a sequence of any characters from the basic or extended character sets and contains at least one non-space character. The significant characters shall be left justified.

A leading space is a space that is located before the first character (letter, number, punctuation mark) in a string data element. Leading spaces, when they occur, are presumed to be significant characters.

A trailing space is a space that is located after the final character (letter, number, punctuation mark) in a string data element. Trailing spaces shall be suppressed unless either:

  • necessary to satisfy a minimum length or
  • a single space is necessary when used in conjunction with another data element for example to maintain word separation

The representation for this data element type is AN.

<string>

::=

{<non_space_char> | <space>} <non_space_char> {<non_space_char> | <space>}

<non_space_char>

::=

<uppercase_letter> | <digit> | <special_char> | <lowercase_letter> | <other_special_char> | <national_char> | <select_language_character> | <ISO_LANGUAGE_CHARACTER>

3.5.1.6 Date

A date data element is used to express the standard date in either YYMMDD or CCYYMMDD format in which CC is the first two digits of the calendar year, YY is the last two digits of the calendar year, MM is the month (01 to 12), and DD is the day in the month (01 to 31). The representation for this data element type is DT.

<date>

::=

<year> <month> <day> | <hundred_year> <year> <month> <day>

<hundred_year>

::=

<digit> <digit>

<year>

::=

<digit> <digit>

<month>

::=

"01" | "02" | ... | "12"

<day>

::=

"01" | "02" | ... | "31"

3.5.1.7 Time

A time data element is used to express the time in HHMMSSd..d format in which HH is the hour for a 24-hour clock (00 to 23), MM is the minute (00 to 59), SS is the second (00 to 59) and d..d is decimal seconds. Seconds and decimal seconds are optional. Trailing zeros in decimal seconds should be suppressed unless necessary to satisfy a minimum length requirement or unless necessary to indicate precision. The representation for this data element type is TM.

<time>

::=

<hour> <minute> [<seconds>]

<hour>

::=

"00" | "01" | "02" | ... | "23"

<minute>

::=

"00" | "01" | "02" | ... | "59"

<seconds>

::=

<integer_seconds> [<decimal_seconds>]

<integer_seconds>

::=

"00" | ... | "59"

<decimal_seconds>

::=

<digit> {<digit>}

3.5.1.8 Binary

The binary data element is any sequence of octets ranging in value from binary 00000000 to binary 11111111. This data element type has no defined maximum length. Actual length is specified by the immediately preceding data element. The binary data element type may only exist in the Binary and Security header segments (see Section 3.11). The representation for this data element type is B.

<binary>

::=

<octet> {<octet>}

<octet>

::=

"000000002" | ... | "111111112"

3.5.2 Data Element Dictionary

The data elements in the dictionary are identified through a reference identifier. Data Elements used solely in Interchange Control Segments (fully described in X12.5 & X12.56), shall have a reference identifier beginning with the leading character 'I'. For each data element, the dictionary specifies the name, description, type, minimum length, and maximum length. For ID data elements, the dictionary lists all code values and their descriptions or a reference where the valid code list can be obtained.

3.5.2.1 Data Element Reference Identifier

Data elements that appear in X12.3 Data Element Dictionary are assigned a unique reference identifier from one to four characters.

<data_element_reference_identifier>

::=

[ "I" ] <unsigned_integer>(01/04)

3.5.2.2 Data Element Type

The following types of data elements, as defined in 3.5.1, appear in the dictionary.

Type Symbol
Numeric Nn (n indicates decimal positions)
Decimal Number R
Identifier ID
Identifier 2 ID2
String AN
Date DT
Time TM
Binary B
3.5.2.3 Data Element Length

Each data element is assigned a minimum and maximum length. The length of the data element value is the number of character positions used except as noted for numeric, decimal, and binary elements.

3.5.2.4 Data Element Name

Data element names shall be unique throughout the X12.3 Data Element Dictionary. A simple data element name shall not duplicate a composite data structure name in the X12.3 Data Element Dictionary or a segment name appearing in the X12.22 Segment Directory.

3.6 Composite Data Structure

The composite data structure is an intermediate unit of information in a segment. By definition, a composite data structure consists of two or more component data elements preceded by a data element separator. In use, in the actual data stream, a composite data structure may appear as only one component data element. Each component data element within the composite data structure, except the last, is followed by a component element separator. The final component data element is followed by the next data element separator or the segment terminator. Trailing component data element separators <us> shall be suppressed. Composite data structures are defined in a composite data structure directory. The directory defines each composite data structure by its name, purpose, reference identifier, and included component data elements in a specified sequence.

A composite data structure is constructed in the following manner:

definition:

<composite_data_structure>

::=

<component_data_element> <us> <component_data_element> {<us> <component_data_element>}

use:

<composite_data_structure>

::=

{[<component_data_element>] <us>} <component_data_element>

3.6.1 Composite Data Structure Reference Identifier

Each composite data structure has a unique four-character reference identifier. The reference identifier serves as a means of locating the composite data structure in the composite data structure directory. The first character is an "S" when the composite data structure is used in a control segment and is a "C" when the composite data structure is used in a data segment. The remaining character positions will contain digits.

<composite_data_structure_identifier>

::=

<composite_identifier_prefix> <digit> <digit> <digit>

<composite_identifier_prefix>

::=

"S" | "C"

3.6.2 Composite Data Structure Name

Composite data structure names shall be unique throughout the X12.3 Data Element Dictionary. A composite data structure name shall not duplicate a simple data element name appearing in the X12.3 Data Element Dictionary or a segment name appearing in the X12.22 Segment Directory.

3.6.3 Component Data Elements in a Composite Data Structure

In defining a composite data structure, each component data element within the composite data structure is further characterized by a condition designator and a data element reference number.

3.6.3.1 Component Data Element Condition Designator

Component data elements shall have a designator that defines their requirement in a composite data structure. These condition designators are represented by a single-character code on the composite data structure diagrams. Refer to Section 3.7.2.2 for the definition of condition designators.

3.6.3.2 Absence of Data

Any component data element that is indicated as mandatory must be included in the composite data structure if the composite data structure is used. Optional component data elements may be omitted if they are not needed. The absence of these component data elements is noted by the occurrence of the component element separators which would have followed them, or, in the case of the last component data element in the composite data structure, by the occurrence of the data element separator or segment terminator. If the optional component data elements being omitted occur at the end of a composite data structure, the structure must be terminated by the occurrence of the next data element separator or the segment terminator following the last used data element value or component data element.

3.7 Data Segment

The data segment is an intermediate unit of information in a transaction set. A data segment consists of a segment identifier; one or more composite data structures or simple data elements, each of which may be permitted to repeat, when so indicated in the segment specification. Adjacent non-repeating simple data elements and composite data structures shall be separated by a data element separator. Adjacent occurrences of the same repeating simple data element or composite data structure in a segment shall be separated by a repetition separator. The data segment shall end with a segment terminator. Trailing data element separators <gs> and trailing repetition separators <rs> shall be suppressed. In use, an instance of a data segment shall contain at least one composite data structure or simple data element, i.e., it shall not consist of only the segment identifier and a segment terminator. Data segments are defined in a data segment directory. The directory defines each segment including the segment's name, purpose, and identifier. The directory also defines composite data structures and data elements that a segment contains in their specified order. A data segment is constructed in the following manner:

definition:

<data_segment>

::=

<seg_id> <gs> <data_segment_unit> {<gs> <data_segment_unit>} <tr>

<data_segment_unit>

::=

<repeating_simple_data_element> | <repeating_composite_data_structure>

<repeating_simple_data_element>

::=

<simple_data_element> {<rs> <simple_data_element>}

<repeating_composite_data_structure>

::=

<composite_data_structure> {<rs> <composite_data_structure>}

use:

<data_segment>

::=

<seg_id> {<gs> [<data_segment_unit>]} <gs> <data_segment_unit> <tr>

<repeating_simple_data_element>

::=

{[<simple_data_element>] <rs>} <simple_data_element>

<repeating_composite_data_structure>

::=

{[<composite_data_structure>] <rs>} <composite_data_structure>

3.7.1 Data Segment Identifier

Each data segment has a unique two- or three-character identifier. This identifier serves as a label for the data segment.

<seg_id>

::=

<letter_or_digit> <letter_or_digit> [<letter_or_digit>]

3.7.2 Data Segment Name

Segment names shall be unique throughout the X12.22 Segment Directory. A segment name shall not duplicate a simple data element name or a composite data structure name appearing in the X12.3 Data Element Dictionary.

3.7.3 Data Elements in a Segment

In defining a segment, each simple data element or composite data structure within the data segment is further characterized by a reference designator and a data element reference number or composite data structure reference identifier. Simple data elements and composite data structures have additional attributes. They shall have a reference designator, a condition designator and a repetition designator. They may also have a semantic note designator.

3.7.3.1 Reference Designator

Each simple data element or composite data structure in a segment is provided a structured code that indicates the segment in which it is used and the sequential position within the segment. The code is composed of the segment identifier followed by a two-digit number that defines the position of the simple data element or composite data structure in that segment. For purposes of creating reference designators, the composite data structure is viewed as the hierarchical equal of the simple data element. Each component data element in a composite data structure is identified by a suffix appended to the reference designator for the composite data structure of which it is a member. This suffix is a two-digit number, prefixed with a hyphen, that defines the position of the component data element in the composite data structure. For example, the third simple element of the BEG segment would be identified as BEG03 because the position count does not include the segment identifier, which is a label. If the fourth position in the BEG segment were occupied by a composite data structure that contained three component data elements, the reference designator for the second component data element would be BEG04-02.

definition:

<ref_desig>

::=

<seg_id> <digit> <digit> ["-"<digit> <digit>]

use:

In use the reference designator does not appear.

3.7.3.2 Condition Designator

Data segment unit or component data element conditions are of three types: mandatory, optional, and relational, and define the circumstances under which a simple data element, composite data structure, or component data element may be required to be present or absent in a particular segment or composite data structure.

3.7.3.2.1 Mandatory Condition

The designation of mandatory is absolute in the sense that there is no dependency on other data segment units or component data elements and may apply to either simple data elements, composite data structures, or component data elements. Mandatory conditions are specified by condition code "M".

Condition Requirement
(M) Mandatory The designated simple data element or composite data structure, whether allowed to repeat or not, must be present in the segment, or the designated component data element must be present in the composite data structure (presence means a data element, composite data structure, or component data element shall not be empty; see Section 3.3.3). If the designation applies to a composite data structure, then at least one value of a component data element in that composite data structure shall be included in the data segment. If the designation applies to a repeating simple data element or a repeating composite data structure then at least one data element value shall be present.
3.7.3.2.2 Optional Condition

The designation of optional means that there is no syntactic requirement for a simple data element or composite data structure to be present in the segment or for a component data element to be present in the composite data structure. Optional conditions are specified by condition code "O".

Condition Requirement
(O) Optional The presence of a value for a simple data element or the presence of a value for any of the component data elements of a composite data structure is at the option of the sender.
3.7.3.2.3 Relational Conditions

Relational conditions may exist among two or more data segment units within the same data segment, or among two or more component data elements within the same composite data structure, based on the presence or absence of one of those data segment units or component data elements (presence means a data element must not be empty). Relational conditions are specified by a condition code and the identity of the subject elements or structures. Relational conditions may not exist between a component data element and anything outside its parent composite data structure.

<relational_cond>

::=

<relation_code> <subj_elem> <subj_elem> {<subj_elem>}

<relation_code>

::=

"P" | "R" | "E" | "C" | "L"

<subj_elem>

::=

<segment_unit_position_in_segment> | <component_element_position_in_composite>

<segment_unit_position_in_segment>

::=

<digit><digit>

<component_element_position_in_composite>

::=

<segment_unit_position_in_segment> "-" <digit><digit>

A data element may be subject to more than one relational condition.

The definitions for each of the <relation_code> values are:

Code Requirement
(P) Paired or Multiple If any <subj_elem> specified in the <relational_cond> is present, then all of the <subj_elem> specified must be present.
(R) Required At least one of the <subj_elem> specified in the <relational_cond> must be present.
(E) Exclusion Not more than one of the <subj_elem> specified in the <relational_cond> may be present.
(C) Conditional If the first <subj_elem> specified in the <relational_cond> is present, then all other <subj_elem> must be present. However, any or all of the <subj_elem> NOT specified as the FIRST <subj_elem> in the <relational_cond> may appear when the first <subj_elem> is not present. The order of the <subj_elem> in the <relational_cond> does not have to be the same as the order of the data elements in the data segment.
(L) List Conditional If the first <subj_elem> specified in the <relational_cond> is present, then at least one of the remaining <subj_elem> must be present. However, any or all of the <subj_elem> NOT specified as the FIRST <subj_elem> in the <relational_cond> may appear when the first <subj_elem> is not present. The order of the <subj_elem> in the <relational_cond> does not have to be the same as the order of the data elements in the data segment.
3.7.3.3 Repetition Designator

The repetition designator may be one, indicating the simple data element or composite data structure may occur no more than once, or contain a specific value greater than one, indicating the maximum number of occurrences of the simple data element or composite data structure.

3.7.3.4 Semantic Notes

A semantic note provides important additional information regarding the intended use of a standard or portion thereof. These usage notes, while not part of the formal syntax, must be followed in order to be in compliance with the standard. Semantic notes, therefore, are considered to be part of the relevant standard and are appropriately designated to distinguish them from syntax notes (which are part of the standard) and comments (which are not part of the standard).

Semantic notes for transaction sets provide information with respect to the intended use of a segment within the context of a particular transaction set. Semantic notes for segments provide information regarding the intended meaning of a designated data element, particularly a generic type, in the context of its use within a specified data segment. Semantic notes may also define relational conditions among data elements in a segment based on the presence of a specific value (or one of a set of values) in one of the data elements.

3.7.4 Absence of Data

Absence of data is represented by the value <empty>. Any value other than <empty> is an indication that data are present. Optional simple data elements and composite data structures and their preceding data element separators that are not needed shall be omitted if they occur at the end of a segment; or, if they do not occur at the end of the segment, the simple data element values or composite data structure values may be omitted, and their absence is indicated by the occurrence of their preceding data element separators, in order to maintain the element's or structure's position as defined in the data segment.

3.8 Transaction Set

The transaction set is a semantically meaningful unit of information exchanged between trading partners. The transaction set shall consist of a transaction set header segment, optionally one or more transaction security header segments, optionally one or more transaction assurance header segments, one or more data segments and loop control segments (if bounded loops exist) in a specified order, one transaction security value segment for each assurance header present, one transaction security trailer segment for each security header segment present, and a transaction set trailer segment.

<transaction_set>

::=

<trans_set_header> <trans_block> <trans_set_trailer>

<trans_block>

::=

<secured_trans_block> | <unsecured_trans_block>

<secured_trans_block>

::=

<trans_security_header> <trans_block> <trans_security_trailer>

<unsecured_trans_block>

::=

<assured_trans_block> | <trans_body>

<assured_trans_block>

::=

<trans_assurance_header> <unsecured_trans_block> <security_value>

<trans_body>

::=

<data_segment_group> {<data_segment_group>}

3.8.1 Transaction Set Header and Trailer

The transaction set header and trailer segments are constructed as follows:

<trans_set_header>

::=

ST <gs> <trans_set_id> <gs> <trans_set_control_number> {<gs> <ic_id_string>} <tr>

<trans_set_trailer>

::=

SE <gs> <number_of_included_segments> <gs> <trans_set_control_number> <tr>

<trans_set_id>

::=

<id>

<trans_set_control_number>

::=

<string>

<ic_id_string>

::=

<string>

<number_of_included_segments>

::=

<unsigned_integer>

The transaction set identifier, <trans_set_id>, uniquely identifies the transaction set. This identifier is the first data element of the transaction set header segment.

The value for the transaction set control number, <trans_set_control_number>, in the header and trailer control segments must be identical for any given transaction. The value for the number of included segments, <number_of_included_segments>, is the total number of segments in the transaction set including the ST and SE segments.

The implementation convention identification string, <ic_id_string>, identifies which implementation convention is in use for the transaction set. Its value may be a reference to a repository, or is available for trading partner definition. This identifier is the optional third data element of the transaction set header segment.

In order to provide sufficient discrimination for the acknowledgment process to operate reliably and to ensure that audit trails are unambiguous, the Transaction Set Control Number (ST02, SE02) shall be unique within a given functional group envelope (GS/GE).

3.8.2 Transaction Security Header and Trailer

The X12.58 Security Structures Standard defines the data formats for authentication, encryption, and assurances in order to provide integrity, confidentiality, and verification and non-repudiation of origin for two levels of exchange of Electronic Data Interchange (EDI)-formatted data defined by Accredited Standards Committee (ASC) X12. These security services can be applied at either the functional group level or the transaction set level or both. Please refer to the X12.58 standard for the construction and usage of the security related segments.

3.8.3 Data Segment Groups

The data segments in a transaction set may be repeated as individual data segments or as unbounded or bounded loops.

<data_segment_group>

::=

<data_segment> | <data_segment_repeat> | <data_segment_loop> | <bounded_loop>

3.8.3.1 Repeated Occurrences of Single Data Segments

When a single data segment is allowed to be repeated, it may have a specified maximum number of occurrences defined at each specified position within a given transaction set standard. Alternatively, a segment may be allowed to repeat an unlimited number of times. The notation for an unlimited number of occurrences is ">1". The ">1" construct is used only if a specific maximum number of occurrences cannot be determined or is unknown. By definition a data segment repeat consists of at least two occurrences. In use, in the actual data stream, it may appear fewer than two times.

definition:

<data_segment_repeat>

::=

<data_segment> <data_segment> {<data_segment>}

use:

<data_segment_repeat>

::=

{<data_segment>}

3.8.3.2 Loops of Data Segments

By definition, loops are groups of two or more semantically related segments. In use, in the actual data stream, a loop may appear as only the loop beginning segment. Data segment loops may be unbounded or bounded.

As part of the transaction set definition, each bounded or unbounded loop is given an identifier, <loop_id>. To prevent ambiguity, each <loop_id> value must be unique in the transaction set definition.

<loop_id>(01/06)

::=

<uppercase_letter_or_digit> {<uppercase_letter_or_digit>}

3.8.3.2.1 Unbounded Loops

In order to establish the start of the loop, the first data segment in the loop shall appear once and only once in each occurrence. The beginning segment of a loop shall not appear elsewhere in the loop. Loops may have a specified maximum number of occurrences. Alternatively, the loop may be specified as having an unlimited number of occurrences. The notation for an unlimited number of repeats is ">1". There is a specified sequence of segments in the loop. Loops themselves are optional or mandatory. The requirement designator of the beginning segment of a loop indicates whether at least one occurrence of the loop is required. Each appearance of the beginning segment defines an occurrence of the loop. The requirement designator of any segment within the loop after the beginning segment applies to that segment for each occurrence of the loop. If there is a mandatory requirement designator for any data segment within the loop after the beginning segment, that data segment is mandatory for each occurrence of the loop.

definition:

<data_segment_loop>

::=

<loop_beg_seg> <loop_body> {<loop_body>}

<loop_beg_seg>

::=

<data_segment>

<loop_body>

::=

<data_segment> | <data_segment_group>

use:

<data_segment_loop>

::=

<loop_beg_seg> {<loop_body>}

If unbounded loops are nested within loops, the inner loop shall not start at the same ordinal position as any outer loop. The inner loop shall not start with the same segment ID as any outer loop, nor may the nested loop contain a segment that is also the beginning segment of any outer loop in the same nesting structure. The inner loop must end before or on the same segment as its immediate outer loop.

3.8.3.2.2 Bounded Loops

The characteristics of unbounded loops described in 3.8.3.2.1 also apply to bounded loops except that bounded loops have no restriction with respect to the beginning segment ID. In addition, bounded loops require a loop start (LS) segment to appear before the first occurrence and a loop end (LE) segment to appear after the last occurrence of the loop. If the loop does not occur within an actual transmission, the LS and LE segments shall be suppressed. The requirement designator on the LS and LE segments must match the requirement designator of the beginning segment of the loop. A bounded loop may contain only one loop structure (a single definition of the included segments) at the level bracketed by the LS and LE segments. Subordinate loops are permissible.

<bounded_loop>

::=

<loop_header> <data_segment_loop> {<data_segment_loop>} <loop_trailer>

<loop_header>

::=

LS <gs> <loop_id> <tr>

<loop_trailer>

::=

LE <gs> <loop_id> <tr>

If bounded loops are nested within loops, the inner loop shall not start at the same ordinal position as any outer loop. The inner bounded loop must end before the immediate outer loop.

Each bounded loop within a transaction set shall have a uniquely defined <loop_id> value of one to six uppercase letters or numeric digits. The corresponding LS and LE segments shall contain the same unique <loop_id> value. The specific <loop_id> values shall be defined in the transaction set standard. In use, the actual LS and LE segments shall contain the defined <loop_id> values. In usage, the <loop_id> will in some transaction sets be necessary to convey segment position or loop hierarchy, or both, within the transaction set.

3.8.4 Data Segments in a Transaction Set

When data segments and control segments are combined to form a transaction set, three characteristics shall be applied to each segment in that usage: a requirement designator, a position in the transaction set definition, and a maximum occurrence.

3.8.4.1 Data Segment Requirement Designator

A data segment shall have one of the following requirement designators indicating its appearance in the data stream of a transmission. These requirement designators are represented by a single character code.

Designator Requirement
(M) Mandatory This data segment shall be included in the transaction set. (Note that a data segment may be mandatory in a loop of data segments, but the loop itself is optional if the beginning segment of the loop is designated as optional.)
(O) Optional The presence of this data segment is at the option of the sending party.
3.8.4.2 Data Segment Position

The ordinal positions of the segments in a transaction set definition are explicitly specified for that transaction set. This positioning shall be maintained during transmission.

3.8.4.3 Data Segment Occurrence

A data segment may have a maximum occurrence of one, a finite number greater than one, or an unlimited number. (See also Section 3.8.3.1)

3.8.4.4 Data Segment Order

A transaction set's segment order shall be defined such that sequential processing of any legitimate instance of the transaction set will result in positive identification of each segment in terms of its ordinal position in the standard. Positive identification shall accordingly be made on the basis of the segment identifiers alone, with the exception of the LS and LE segments, where the identification is made using the segment identifier in conjunction with the <loop_id>. Positive identification shall not depend on a segment's requirement designator or maximum occurrences.

3.9 Functional Group

A functional group shall consist of a functional group header segment, optionally one or more functional security header segments, optionally one or more functional assurance header segments, one or similar transaction sets, one functional security value segment for each assurance header present, one functional security trailer segment for each security header segment present, and a functional group trailer segment.The functional identifier (<function_id>) defines the collection of transaction sets that may be included within the functional group.

<functional_group>

::=

<function_header> <function_block> <function_trailer>

<functional_block>

::=

<secured_function_block> | <unsecured_function_block>

<secured_function_block>

::=

<function_security_header> <function_block> <function_security_trailer>

<unsecured_function_block>

::=

<assured_function_block> | <function_body>

<assured_function_block>

::=

<function_assurance_header> <unsecured_function_block> <security_value>

<function_body>

::=

<transaction_set> {<transaction_set>}

3.9.1 Functional Group Header and Trailer

The functional group header and trailer segments are constructed as follows:

<function_header>

::=

GS <gs> <function_id> <gs> <app_sender_id> <gs> <app_receiver_id> <gs> <fg_date> <gs> <fg_time> <gs> <function_control_number> <gs> <standard> <gs> <version> <tr>

<function_id>

::=

<id>

<app_receiver_id>

::=

<string>

<app_sender_id>

::=

<string>

<fg_date>

::=

<date>

<fg_time>

::=

<time>

<function_control_number>

::=

<numeric>

<standard>

::=

<id>

<version>

::=

<string>

<function_trailer>

::=

GE <gs> <no_included_trans_sets> <gs> <function_control_number> <tr>

<no_included_trans_sets>

::=

<numeric>

The functional group control number, <function_control_number>, in the header and trailer control segments shall be the same for any given group. The number of included transaction sets, <no_included_trans_sets>, is the total number of transaction sets in the group.

In order to provide sufficient discrimination for the acknowledgment process to operate reliably and to ensure that audit trails are unambiguous, the combination of Functional ID Code (GS01), Application Sender's ID (GS02), Application Receiver's ID (GS03), and Functional Group Control Numbers (GS06, GE02) shall by themselves be unique within a reasonably extended time frame whose boundaries shall be defined by trading partner agreement. Because at some point it may be necessary to reuse a sequence of control numbers, the Functional Group Date and Time may serve as an additional discriminant only to differentiate functional group identity over the longest possible time frame.

3.9.2 Functional Security Header and Trailer

The X12.58 Security Structures Standard defines the data formats for authentication, encryption, and assurances in order to provide integrity, confidentiality, and verification and non-repudiation of origin for two levels of exchange of Electronic Data Interchange (EDI) formatted data defined by Accredited Standards Committee (ASC) X12. These security services can be applied at either the functional group level or the transaction set level or both. Please refer to the X12.58 standard for the construction and usage of the security-related segments.

3.10 Control Segment

A control segment has the same structure as a data segment but is used for transferring control information rather than application information. Control segments referred to in this standard are fully described in X12.22 Segment Directory.

3.10.1 Loop Control Segments

Loop control segments are used only to delineate bounded loops. Delineation of the loop shall consist of the loop header (LS segment) and the loop trailer (LE segment). The loop header defines the start of a structure that must contain one or more iterations of a loop of data segments and provides the loop identifier for this loop. The loop trailer defines the end of the structure. The LS segment appears only before the first occurrence of the loop, and the LE segment appears only after the last occurrence of the loop.

3.10.2 Transaction Set Control Segments

The transaction set is delineated by the transaction set header (ST segment) and the transaction set trailer (SE segment). The transaction set header starts and identifies the transaction set. The transaction set trailer defines the end of the transaction set and provides a count of the data segments, which includes the ST and SE segments.

3.10.3 Functional Group Control Segments

The functional group is delineated by the functional group header (GS segment) and the functional group trailer (GE segment). The functional group header starts and identifies one or more related transaction sets and provides a control number and application identification information. The functional group trailer defines the end of the functional group of related transaction sets and provides a count of contained transaction sets.

3.10.4 Security Control Segments

The security control segments are used to provide data integrity, confidentiality, verification of origin and non-repudiation of origin by delineating information for authentication, encryption, and compression. The X12.58 Security Structures Standard defines the data formats and business usage for these security services. Please refer to this standard for the construction and usage of the security-related segments.

3.10.5 Relations among Control Segments

The control segments of this standard shall have a nested relationship as is shown and annotated in this subsection. The letters preceding the control segment name are the segment identifier for that control segment. The indentation of segment identifiers shown below indicates the subordination among control segments. Security segments are optional.

GS Functional Group Header starts a group of related transaction sets.

Functional Group Security and Assurance header segments, if used, shall be inserted here. Please refer to the X12.58 Security Structures Standard for the construction and usage of the security-related segments.

ST Transaction Set Header, starts a transaction set.

Transaction Set Security and Assurance header segments, if used, shall be inserted here. Please refer to the X12.58 Security Structures Standard for the construction and usage of the security-related segments.

LS Loop Header, starts a bounded loop of data segments but is not part of the loop.

LS Loop Header, starts an inner, nested, bounded loop.

LE Loop Trailer, ends an inner, nested, bounded loop.

LE Loop Trailer, ends a bounded loop of data segments but is not part of the loop.

Transaction Set Security and Assurance trailer segments, if used, shall be inserted here. Please refer to the X12.58 Security Structures Standard for the construction and usage of the security-related segments.

SE Transaction Set Trailer, ends a transaction set.

Functional Group Security and Assurance trailer segments, if used, shall be inserted here. Please refer to the X12.58 Security Structures Standard for the construction and usage of the security-related segments.

GE Functional Group Trailer, ends a group of related transaction sets.

More than one ST/SE pair, each representing a transaction set, may be used within one functional group. Also more than one LS/LE pair, each representing a bounded loop, may be used within one transaction set.

3.11 Binary Segment

A binary segment, BIN or BDS, has the same structure as a data segment but is used for transferring binary data with an accompanying length parameter. The BDS segment also contains a filter parameter. The filter parameter specifies the encoding algorithm, if any. Bit patterns normally reserved for other functions may appear in the binary data element. These bit patterns could be misinterpreted. The length of the binary data element is provided in the preceding data element in order to locate the end of the binary data and prevent such misinterpretation. The binary segment may not occur outside the boundaries of a transaction set.

<binary_seg>

::=

BIN <gs> <number_of_octets> <gs> <binary> <tr> | BDS <gs> <filter_id> <gs> <number_of_octets> <gs> <binary> <tr>

<number_of_octets>

::=

<unsigned_integer>

<filter_id>

::=

<id>

The data element that references the number of octets provides a count of all octets contained in the binary data element. This count does not include the preceding data element separator or trailing data segment terminator. The count is provided to enable finding the data segment terminator.