About ANSI X.12
History
In 1979, the American National Standards Institute (ANSI) chartered the Accredited Standards Committee (ASC) X12 to develop uniform standards for inter-industry electronic exchange of business transactions (Electronic Data Interchange, EDI).
ANSI X12 (or just short X12) was originally conceived to support companies across different industry sectors in North America. However actually companies worldwide are using X12 EDI standards in daily business transactions. ASC X12 also contributes to UN/EDIFACT messages that are used widely outside of the United States.
The official X12 website can be found here.
Subcommitees
The Accredited Standards Committee (ASC) is actually divided in following Subcommittees:
X12C - Communications & Controls X12F - Finance X12I - Transportation X12J - Technical Assessment X12M - Supply Chain X12N - Insurance
X12 File Structure
In general a X12 file is structured like this:
+----- Interchange Control Header ISA Mandatory | +--- Functional Group Header GS Conditional | | +- Transaction Set Header ST Mandatory | | | Transaction Data As required | | +- Transaction Set Trailer SE Mandatory | +--- Functional Group Trailer GE Conditional +----- Interchange Control Trailer IEA Mandatory
X12 Delimiters
X12 is using the following delimeters:
Segment delimiter ~ tilde Hex: 0x7E Element delimiter * asterisk Hex: 0x2A Subelement delimiter : colon Hex: 0x3A
Transaction Sets
For each of the above mentioned Subcommittees there are defined Transaction Sets available. Actually there are more than 300 Transaction Sets defined for different business processes.
The Transaction Set is composed of logically related pieces of information grouped into units called Segments. For example, one Segment used in the Transaction Set might convey the address. A Transaction Set may contain multiple Segments. For example, the Address Segment might be used repeatedly to convey multiple sets of address information.
The X12 standard defines the sequence of segments in the Transaction Set and also the sequence of elements within each segment. The relationship between segments and elements can be compared to the relationship between records and fields in a database environment.
Each Transaction Set contains:
-
Transaction Set header (designated ST)
-
Transaction Set trailer (designated SE)
-
Single message, enveloped within the header and trailer
A Transaction Set has a three-digit code, a text title, and a two-letter code, for example: 850, Purchase Orders, PO.
Find here a complete list of ANSI X.12 Transaction Sets with their Transaction Set ID (3 digits), Function Group Code (2 digits), Description, Subcommittee and Category.
Example for 850 Purchase Order
The following data is a very simple example of an 850 Purchase Order:
ST*850*1~ Transaction Set Header BEG*00*NE*PO123456**20171129~ Beginning Segment for Purchase Order REF*CR*ABC~ Reference Identification DTM*074*20171201~ Date/Time Reference N1*BY**15*1234567890123~ Name (Buyer) N1*SE**15*9876543210987~ Name (Seller) N1*ST**15*4567890123456~ Name (Ship To) PO1*1*10*EA*9.99*PE*EN*4123456789012~ Line Item with quantity, price, GTIN CTT*1*10~ Transaction Totals SE*10*1~ Transaction Set Trailer