Example 2
INREC FIELDS=(1,35,2Z,36,45)
MERGE FIELDS=(20,4,CH,D,10,3,CH,D),FILES=3
SUM FIELDS=(36,4,BI,40,8,PD)
RECORD TYPE=F,LENGTH=(80,,82)
This example illustrates how overflow of a summary field can be prevented when three fixed-length data sets are merged and reformatted for output. The input record size is 80 bytes. To illustrate the use of the RECORD statement, assume that SORTIN and SORTOUT are not present (that is, all input/output is handled by user exits).
- Position
- Contents
- 1-35
- Input positions 1 through 35
- 36-37
- Binary zeros (to prevent overflow)
- 38-82
- Input positions 36 through 80
The MERGE and SUM statements must refer to the fields of the reformatted input records.
The reformatted output records are identical to the reformatted input records.
Thus, the 2-byte summary field at positions 36 and 37 in the original input records expands to a 4-byte summary field in positions 36 through 39 of the reformatted input/output record before merging. This prevents overflow of this summary field.
Restriction: If OUTREC were used instead of INREC, the records would be reformatted after merging, and the 2-byte summary field might overflow.