Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Example 17 z/OS DFSORT Application Programming Guide SC23-6878-00 |
|
This example illustrates how you can INCLUDE groups of VB records between a header and a trailer. It's similar to Example 16, but here the records are variable-length. For the FB records, we could add the ID after the end of each record and then remove it without changing the records. But we can't add the ID at the end of each VB record because that would pad all of the records to a fixed length. So, instead we insert the ID between the RDW and the first data byte of each record, and later remove it. The VB input records might look like this:
In the output data set we only want to include groups of records that start with 'HDR' and end with 'TRL'. We use an IFTHEN WHEN=INIT clause to reformat each record so it
has room for the ID byte between the RDW and the first data byte.
After the WHEN=INIT clause is executed, the intermediate records
look like this:
Note that position 5 is blank and the 'HDR' and 'TRL' characters have been shifted over to positions 6-8. We use an IFTHEN WHEN=GROUP clause to put a non-blank character
in each record that is part of a group. BEGIN indicates a group starts
with a record that has 'HDR' in positions 6-8. END indicates a group
ends with a record that has 'TRL' in positions 6-8. PUSH overlays
a 1-byte ID character at position 5 in each record of a group. After
the IFTHEN GROUP clause is executed, the intermediate records look
like this:
Note that the records within a group have a non-blank character in position 5 whereas the records outside groups have a blank character in position 5. The ID starts at 1 for the first group and is incremented by 1 for each subsequent group. Since we are only allowing one character for the ID, when the ID counter gets to 10, a '0' will appear in position 5. That's fine since we are just looking for a non-blank to indicate a record within a group, or a blank to indicate a record outside of a group. We use an OUTFIL statement to only INCLUDE records with a non-blank
in position 5, and to remove the ID character 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:
|
Copyright IBM Corporation 1990, 2014
|