Concatenated fields

Using the CONCAT keyword, you can combine two or more fields from a physical file record format to make one field in a logical file record format.

For example, a physical file record format contains the fields Month, Day, and Year. For a logical file, you concatenate these fields into one field, Date.

The field length for the resulting concatenated field is the sum of the lengths of the included fields (unless the fields in the physical file are binary or packed decimal, in which case they are changed to zoned decimal). The field length of the resulting field is automatically calculated by the system. A concatenated field can have:
Note: This editing and validity checking information is not used by the database management system but is retrieved when field descriptions from the database file are referred to in a display or printer file.
When fields are concatenated, the data types can change (the resulting data type is automatically determined by the system). The following rules and restrictions apply:
Note: For information about concatenating DBCS fields, see Double-byte character set considerations.
When only numeric fields are concatenated, the sign of the last field in the group is used as the sign of the concatenated field.
Notes:
  1. Numeric fields with decimal precision other than zero cannot be included in a concatenated field.
  2. Date, time, timestamp, and floating-point fields cannot be included in a concatenated field.

The following example shows the field description in data description specifications (DDS) for concatenation. (The CONCAT keyword is used to specify the fields to concatenate.)

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A
00101A            MONTH
00102A            DAY
00103A            YEAR
00104A            DATE                      CONCAT(MONTH DAY YEAR)
     A
In this example, the logical file record format includes the separate fields of Month, Day, and Year, as well as the concatenated Date field. Any of the following formats can be used:

When both separate and concatenated fields exist in the format, any updates to the fields are processed in the sequence in which the DDS is specified. In the previous example, if the Date field contained 103188 and the Month field is changed to 12, when the record is updated, the month in the Date field would be used. The updated record would contain 103188. If the Date field were specified first, the updated record would contain 123188.

Concatenated fields can also be used as key fields and select/omit fields.