The segment

A database record consists of one or more segments, and the segment is the smallest piece of data IMS can store.

Here are some additional facts you need to know about segments:

Segments consist of two parts (a prefix and the data), except when using a SHSAM or SHISAM database. In SHSAM and SHISAM databases, the segment consists of only the data. In a GSAM database, segments do not exist.

The following figure shows the format of a fixed-length segment.

Figure 1. Format of fixed-length segments
Prefix has 1-byte segment code, 1-byte delete byte, variable-byte pointer and counter area. Fixed-length data portion has a sequence field and data fields with lengths specified for the segment type.

The following figure shows the format of a variable-length segment.

Figure 2. Format of variable-length segments
Prefix is the same as a fixed-length segment. Data portion has a 2-byte size field, sequence field, and data fields with lengths varying between minimum and maximum size specified for the segment type.

IMS uses the prefix portion of the segment to manage the segment. The prefix portion of a segment consists of: segment code, delete byte, and in some databases, a pointer and counter area. Application programs do not see the prefix portion of a segment. The data portion of a segment contains your data, arranged in one or more fields.