Example 11
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.
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)