SORT – How to use VB dataset (VLSHRT)
When you want the sort to present your input numeric field in a format that you want in your
A record in a VB data set looks like this:
|RDW||Fixed data||Variable data|
The RDW (Record Descriptor Word) is a 4-byte binary field with the length of the record in the first two bytes. Fixed data consists of data bytes that are present in every record. Variable data consists of one or more data bytes that may or may not be present in every record, so different records can have different lengths up to the maximum logical record length (LRECL) for the data set.
Please note the difference in the statements for FB and VB datasets.
If you want to sort bytes from 11 to 15 in ascending order
- FB Dataset
- VB dataset
Because first 4 bytes is RDW as described above.
In the above scenario for VB dataset, the control fields are from position 15-19. Suppose if few of the records did not have values in these control bytes, the SORT will fail. To avoid this, we can make use of option VLSHRT.
VLSHRT tells DFSORT that you want to temporarily replace any missing control field bytes with binary zeros (the zeros are not kept for the output record), thus allowing DFSORT to validly sort or merge on the short control fields.