FIELD statement overview

The FIELD statement defines a field within a segment type.

A FIELD statement is required for the following types of fields:
  • Sequence field in a segment
  • Fields that an application program refers to by name in a segment search argument (SSA) of a DL/I call
  • Fields referenced in a SENFLD statement in a PSB
  • Fields referenced in an XDFLD statement

In the FIELD statements for each of the preceding field types, you must specify the NAME parameter. When the NAME parameter is specified, the field name is stored in the database data management block (DMB). To save storage in the DMB, specify the EXTERNALNAME parameter only, unless the NAME parameter is required.

You can also code FIELD statements to define data fields and structures to IMS™ that would otherwise be defined only in application source code or copy books. The advantage to coding these optional FIELD statements is that, when the IMS catalog is enabled, application developers and others can query the IMS catalog for metadata about these data fields and structures, instead of having to locate the application source code or generate the metadata by using IMS Enterprise Suite Explorer for Development. For these types of optional FIELD statements, if you code the EXTERNALNAME parameter, the NAME parameter is not required.

FIELD statements can be put in the input deck in any order, except in the following cases:
  • FIELD statements must immediately follow the SEGM statement to which they are related.
  • A sequence field, if one is defined, must always be first
  • If a FIELD statement specifies the CASENAME parameter, the FIELD statement must follow the DFSCASE statement that is specified on the CASENAME parameter
  • If a FIELD statement specifies the DEPENDSON parameter, the FIELD statement must follow the FIELD statement that is specified on the DEPENDSON parameter
  • If a FIELD statement specifies the REDEFINES parameter, the FIELD statement must follow the FIELD statement that is specified on the REDEFINES parameter
  • If a FIELD statement specifies the STARTAFTER parameter, the FIELD statement must follow the FIELD statement that is specified on the STARTAFTER parameter
  • If a FIELD statement specifies the PARENT parameter, the FIELD statement must follow the FIELD statement that is specified on the PARENT parameter

You can define up to 1,000 fields in a database.

Within each segment type, you can include up to 255 FIELD statements that specify the NAME parameter. The NAME parameter enables a field for SSA searches. If you omit the NAME parameter, there is no limit to the number of FIELD statements that you can define for a segment, as long as the number of fields defined does not exceed the maximum of 1000 fields for the database. However, fields defined without the NAME parameter cannot be specified on an SSA and are not searchable by IMS.

The definition of fields within a segment can overlap. For example, a date field within a segment can be defined as three 2-byte fields and also as one 6-byte field as shown in the following figure.

Figure 1. Example of a date field within a segment defined as three 2–byte fields and one 6–byte field
begin figure description. This figure is described in the surrounding text. end figure description.

The technique of overlapping field definitions allows application programs to access the same piece of data in various ways. To access the same piece of data in various ways, you code a separate FIELD statement for each field. For the example shown, you would code four FIELD statements, one for the total 6-byte date and three for each 2-byte field in the date.