z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 5

z/OS DFSORT Application Programming Guide
SC23-6878-00

 * Add Z'0' before the ZD SUM field to prevent overflow.
 * Add P'0' before the PD SUM field to prevent overflow.
  INREC FIELDS=(1,10,  Copy bytes before ZD SUM field
    11:C'0',12:11,4,   Add Z'0' before ZD SUM field
    16:15,6,           Copy bytes after ZD SUM field
    22:X'00',23:21,2,  Add P'0' before PD SUM field
    25:23,5,           Copy SORT field
    30:28,53)          Copy bytes after SORT field
 * Sort on key in its new position.
  SORT FIELDS=(25,5,CH,A)
 * Sum on the expanded ZD and PD fields in
 * their new positions.
  SUM FIELDS=(11,5,ZD,22,3,PD)

These statements illustrate a technique for preventing overflow of summed fields by using INREC to make the fields larger before they are summed.

The fields that might overflow when they are summed are a 4 byte ZD field starting at position 11 and a 2 byte PD field starting at position 21. In order to prevent them from overflowing, we expand each field on the left with an appropriate zero byte; C'0' (Z'0') for the ZD field and P'0' (X'00') for the PD field. We can then sum on the new 5 byte ZD field and on the new 3 byte PD field.

Note that adding these extra bytes increases the length of the record and changes the starting position of various fields. In the SORT and SUM statements, we must specify the starting positions of the fields in the reformatted record rather than the starting positions of the fields in the input record. For example, although the SORT field starts in position 23 in the input record, we must use its starting position of 25 in the reformatted record.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014