Example 18
SORT FIELDS=(1,12,CH,A)
OUTREC OVERLAY=(30:16,8,Y4T,TOGREG=Y4T)
OUTFIL INCLUDE=(30,1,CH,EQ,C'*')
This example illustrates how to list records with dates outside of the valid range (for example, a month not between 01-12).
Note: Dates with an invalid digit (A-F) can
result in a data exception (0C7 ABEND).
The input records might be as follows:
Betten 20091021
Vezinaw 20091101
Casad 00000000
Boenig 20091325
Kolusu 20090931
Yaeger 20090731
The SORT statement sorts the records by the name
in positions 1-12. After the SORT statement is processed, the sorted
records will look like this:
Betten 20091021
Boenig 20091325
Casad 00000000
Kolusu 20090931
Vezinaw 20091101
Yaeger 20090731
The OUTREC statement uses TOGREG to convert each
ccyymmdd value in positions 16-23 to a ccyymmdd value in positions
30-37; the third column will be identical to the second column for
valid dates and special indicators, but will contain asterisks for
invalid dates. After the OUTREC statement is processed, the reformatted
records will look like this:
Betten 20091021 20091021
Boenig 20091325 ********
Casad 00000000 00000000
Kolusu 20090931 ********
Vezinaw 20091101 20091101
Yaeger 20090731 20090731
The OUTFIL statement selects the records that have
an asterisk in position 30, that is, the records with an invalid date.
The Boenig record is invalid because mm is 13, and the Kolusu record
is invalid because mm is 09 but dd is 31 (September only has 30 days).
Note that the special indicator of all 0s for the Casad record is
valid. The output records would be as follows:
Boenig 20091325 ********
Kolusu 20090931 ********