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
SORT FIELDS=(11,5,CH,A)
- VB dataset
SORT FIELDS=(15,5,CH,A)
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.
OPTION VLSHRT
SORT FIELDS=(15,5,CH,A)
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.
——————————————————————————————————–
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
——————————————————————————————————–
You may also like to look at:
Working on Mainframes – Is Change to a different technology necessary |
Pingback: SORT – PARSE – READ EXCEL (CSV) FILE IN MAINFRAMES | F1 for Mainframe