Loops and blocks

The loops and blocks within a transaction set appear under the same category where the transaction set definition itself is located.

Loops are groups of two or more semantically related segments, though in an actual X12 transmission, a loop can appear as only the single loop that starts a segment. Loops can also contain other loops as components.

X12 defines two types of loops: unbounded and bounded. In unbounded loops, the first data segment in the loop appears once and only once in each loop occurrence (marking the start of an occurrence). Bounded loops are similar, but have no restriction on which data segment begins a loop occurrence and require a loop start (LS) segment before the first loop occurrence and a loop end (LE) segment after the last loop occurrence.

The type name of a loop is Loop followed by the identifier of the first segment in that loop and, if defined for the transaction set, the numeric Loop ID value that is specified by X12. For example, X12 version 4010 defines two different loops in transaction set #124, which begin with segment LM, loop IDs 3200 and 3320. These loops are named LoopLM3200 and LoopLM3320 respectively. If no numeric Loop ID values are specified for a transaction set and the same segment ID begins more than one loop, the sequential position of each loop within the transaction set is used to create unique loop names.

For example, version 4010, transaction set #151 has three different loops, which begin with segment PBI, named LoopPBI1, LoopPBI2, and LoopPBI3. Then there is more than one transaction set under a category, loop and block definitions for a specific transaction set are found under a category whose name begins with the functional group ID code, and is followed by the transaction set number. For example, the loops in transaction set #844 are subtypes of category CF844.

All bounded loop definitions for a transaction set appear under a group named Block. All bounded loops begin with an LS Segment, followed by the loop definition for the loop data segments and then an LE