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


Example 28

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

  OPTION COPY
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8:5)),
    IFTHEN=(WHEN=GROUP,BEGIN=(8,5,CH,EQ,C'PAGE:'),
    PUSH=(5:SEQ=3))
  OUTFIL INCLUDE=(5,3,ZD,EQ,2,OR,5,3,ZD,EQ,3),
    BUILD=(1,4,5:8)

This example illustrates how you can INCLUDE specific relative records from groups of VB records. We insert a sequence number between the RDW and the first data byte of each record. The sequence number restarts at 1 for the first record in each group. We INCLUDE on the sequence number and then remove it.

The VB input records might look like this:
Len|Data
 12|PAGE:  1
 22|LINE 1 OF REPORT A
 22|LINE 2 OF REPORT A
 22|LINE 3 OF REPORT A
 22|LINE 4 OF REPORT A
   |...
 12|PAGE:  2
 23|LINE 66 OF REPORT A
 23|LINE 67 OF REPORT A
 23|LINE 68 OF REPORT A
 23|LINE 69 OF REPORT A
   |...
 12|PAGE:  3
 24|LINE 131 OF REPORT A
 24|LINE 132 OF REPORT A
 24|LINE 133 OF REPORT A
 24|LINE 134 OF REPORT A
   |...
We use an IFTHEN WHEN=INIT clause to reformat each record so it has room for the 3-byte sequence number between the RDW and the first data byte. After the WHEN=INIT clause is executed, the intermediate records look like this:
Len|Data
 15|   PAGE:  1
 25|   LINE 1 OF REPORT A
 25|   LINE 2 OF REPORT A
 25|   LINE 3 OF REPORT A
 25|   LINE 4 OF REPORT A
   |   ...
 15|   PAGE:  2
 26|   LINE 66 OF REPORT A
 26|   LINE 67 OF REPORT A
 26|   LINE 68 OF REPORT A
 26|   LINE 69 OF REPORT A
   |   ...
 15|   PAGE:  3
 27|   LINE 131 OF REPORT A
 27|   LINE 132 OF REPORT A
 27|   LINE 133 OF REPORT A
 27|   LINE 134 OF REPORT A

Note that positions 5-7 are blank and the 'PAGE:' characters have been shifted over to positions 8-12.

We use an IFTHEN WHEN=GROUP clause to put a 3-byte sequence number in each record. BEGIN indicates a group starts with a record that has 'PAGE:' in positions 8-12. PUSH overlays a 3-byte sequence number at positions 5-7 of each record. The sequence number starts at 1 for the first record of a group and is incremented by 1 for each subsequent record of the group. After the IFTHEN GROUP clause is executed, the intermediate records look like this:
Len|Data
 15|001PAGE:  1
 25|002LINE 1 OF REPORT A
 25|003LINE 2 OF REPORT A
 25|004LINE 3 OF REPORT A
 25|005LINE 4 OF REPORT A
   |006...
 15|001PAGE:  2
 26|002LINE 66 OF REPORT A
 26|003LINE 67 OF REPORT A
 26|004LINE 68 OF REPORT A
 26|005LINE 69 OF REPORT A
   |006...
 15|001PAGE:  3
 27|002LINE 131 OF REPORT A
 27|003LINE 132 OF REPORT A
 27|004LINE 133 OF REPORT A
 27|005LINE 134 OF REPORT A
   |006...

Note that the records in each group are numbered starting with 001 for the first record of each group. The records we want have sequence numbers 002 and 003.

We use an OUTFIL statement to only INCLUDE the records with sequence number 002 or 003, and to remove the sequence numbers so the included output records will be identical to the input records. After the OUTFIL statement is executed, the final output records look like this:
Len|Data
 22|LINE 1 OF REPORT A
 22|LINE 2 OF REPORT A
 23|LINE 66 OF REPORT A
 23|LINE 67 OF REPORT A
 24|LINE 131 OF REPORT A
 24|LINE 132 OF REPORT A

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014