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


Example 11

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

  OPTION COPY
  OUTREC IFTHEN=(WHEN=INIT,
            OVERLAY=(81:11,10,
              11:81,10,ZD,DIV,+1200,TO=PD,LENGTH=6,
              17:81,10,ZD,MOD,+1200,TO=PD,LENGTH=4)),
         IFOUTLEN=80         

In the previous example (Example 10), we used OVERLAY to overlay positions 31-40 with PD fields for the quotient and remainder of the 10-byte ZD value at positions 11-20 divided by +1200. In this example, we want to overlay positions 11-20 with the quotient and remainder. The input records are 80 bytes and fixed-length and we want the output records to be 80 bytes and fixed-length as well.

If we just overlaid the fields directly as before, we would "ruin" the ZD value before we could use it to get the remainder; the PD quotient would overlay positions 11-16, so positions 11-20 would no longer contain the ZD value we need to get the remainder.

In order to overlay the ZD value itself with the PD values, we make a copy of the 10 byte ZD value after the end of the record, and then overlay the original ZD value with the quotient and remainder derived from the copy of the ZD value.

By making a copy of the 10 byte ZD value at the end of the record, we extend the record length from 80 bytes to 90 bytes. Since we want the final record length to be 80 bytes, we must remove the extra 10 bytes. So instead of just using the OVERLAY parameter, we use an IFTHEN WHEN=INIT clause with OVERLAY, and IFOUTLEN=80. Alternatively, we could use an OVERLAY parameter on the OUTREC statement, followed by an OUTFIL statement, to remove the extra 10 bytes like this:
  OPTION COPY
  OUTREC OVERLAY=(81:11,10,
               11:81,10,ZD,DIV,+1200,TO=PD,LENGTH=6,
               17:81,10,ZD,MOD,+1200,TO=PD,LENGTH=4)
  OUTFIL OUTREC=(1,80)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014