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


Example 1

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

DATASORT FROM(INPUT) TO(OUTPUT) HEADER TRAILER USING(CTL1)

This example shows how you can sort the data records between a header record (first record) and a trailer record (last record).

The CTL1CNTL data set contains:
  SORT FIELDS=(16,13,CH,A)
The input records look like this:
MM9999900510100823DDDDD FFFFF 004200806128
AAR   FIRST C  1134341444441     XXXXXXXXX
ATX   SECOND   7777777770111     XXXXXXXXX
ATX   THIRD L  6297132201111     XXXXXXXXX
ATX   FOURTH   2830012906356     XXXXXXXXX
MM9999900510100823DDDDD FFFFF 004

We want to keep the MM records in place and sort the other records by the CH field in positions 16-28. We use HEADER and TRAILER to indicate the first and last records should not be sorted. We use the SORT statement to SORT ascending on positions 16-28.

The output records would look like this:
MM9999900510100823DDDDD FFFFF 004200806128
AAR   FIRST C  1134341444441     XXXXXXXXX
ATX   FOURTH   2830012906356     XXXXXXXXX
ATX   THIRD L  6297132201111     XXXXXXXXX
ATX   SECOND   7777777770111     XXXXXXXXX
MM9999900510100823DDDDD FFFFF 004

Note that we could use FIRST and LAST instead of HEADER and TRAILER.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014