Sometimes I have to edit a VB dataset with a big LRECL. Unfortunately EDIT shifts to browse mode because there is not enough memory available for my TSO session. This is annoying because the total amount of bytes in the VB dataset may easily be processed by an EDIT session. The problem is that EDIT allocates memory as if every record is as long as the maximum LRECL indicates and thus EDIT goes into browse mode.
If I am lucky I can process the dataset using EDIT by copying the data from the VB dataset to another VB dataset having a LRECL that corresponds to the longest record in the dataset. But how do you find the longest record in a VB dataset. Once again SORT comes in handy:
For VB datasets SORT includes the first four bytes of each record. No other programs cares about those four bytes. The first two bytes of these four bytes contains the length of the record. Keeping hold of this thought it is easy to get the idea used in the above example. After execution the dataset MY.LONGEST.RECORD only contains one record and this record is the longest in MY.VB.DATASET. By entering BROWSE on MY.LONGEST.RECORD and execute a FIND P'=' LAST I have found the length of the longest record. Then you just have to pray that this length is a lot shorter than the original LRECL. If so you can copy the data from MY.VB.DATASET to another dataset having a LRECL that fits the longest record from MY.VB.DATASET. After doing the copy I can try to EDIT the new dataset and hope it does not shift to BROWSE mode.
Please notice the trick by entering BROWSE on MY.LONGEST.RECORD. If you use EDIT then FIND P'=' LAST locates the last of the spaces which EDIT pads the record with in order to have a record with LRECL and then the mission is not accompished.