Sign in

docs RPG Reference

Split Control Field

Split Control Field

A split control field is formed when you assign more than one field in an input record the same control level indicator. For a program described file, the fields that have the same control level indicator are combined by the program in the order specified in the input specifications and treated as a single control field (see Figure 1). The first field defined is placed in the high-order (leftmost) position of the control field, and the last field defined is placed in the low-order (rightmost) position of the control field.

Figure 1. Split Control Fields

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC................................
I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr....
IMASTER        01
I                                 28   31  CUSNO         L4
I                                 15   20  ACCTNO        L4
I                                 50   52  REGNO         L4

For an externally described file, fields that have the same control level indicator are combined in the order in which the fields are described in the data description specifications (DDS), not in the order in which the fields are specified on the input specifications. For example, if these fields are specified in DDS in the following order:

  • EMPNO
  • DPTNO
  • REGNO

and if these fields are specified with the same control level indicator in the following order on the input specifications:

  • REGNO L3
  • DPTNO L3
  • EMPNO L3

the fields are combined in the following order to form a split control field: EMPNO DPTNO REGNO.

Some special rules for split control fields are:

  • For one control level indicator, you can split a field in some record types and not in others if the field names are different. However, the length of the field, whether split or not, must be the same in all record types.
  • You can vary the length of the portions of a split control field for different record types if the field names are different. However, the total length of the portions must always be the same.
  • A split control field can be made up of a combination of packed decimal fields and zoned decimal fields so long as the field lengths (in digits or characters) are the same.
  • You must assign all portions of a split control field in one record type the same field record relation indicator and it must be defined on consecutive specification lines.
  • When a split control field contains a date, time, or timestamp field than all fields in the split control field must be of the same type.

Figure 2 shows examples of the preceding rules.

Figure 2. Split Control Fields — Special Rules

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC................................
I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr....
IDISK      BC  91   95 C1
I         OR   92   95 C2
I         OR   93   95 C3
I
 * All portions of the split control field must be assigned the same
 * control level indicator and all must have the same field record
 * relation entry.
I                                  1    5  FLD1A         L1
I                                 46   50  FLD1B         L1
I                                 11   13  FLDA          L2
I                                 51   60  FLD2A         L3
I                                 31   40  FLD2B         L3
I                                 71   75  FLD3A         L4  92
I                                 26   27  FLD3B         L4  92
I                                 41   45  FLD3C         L4  92
I                                 61   70  FLDB              92
I                                 21   25  FLDC              92
I                                  6   10  FLD3D         L4  93
I                                 14   20  FLD3E         L4  93

The record identified by a ‘1’ in position 95 has two split control fields:

  1. FLD1A and FLD1B
  2. FLD2A and FLD2B

The record identified with a ‘2’ in position 95 has three split control fields:

  1. FLD1A and FLD1B
  2. FLD2A and FLD2B
  3. FLD3A, FLD3B, and FLD3C

The third record type, identified by the 3 in position 95, also has three split control fields:

  1. FLD1A and FLD1B
  2. FLD2A and FLD2B
  3. FLD3D and FLD3E