We can optimize our search of the VTOC for a specific Format 1 DSCB using a Search KEY Equal CCW command instead of reading each record and checking to see if it matches our data set name.
In our CCW program we replace our Search ID to a Search KEY Equal command. We need to change our read from a Read Key/Data to only read the Data. Here is our CCW program to search a track for a specific DSCB.
DC X'07',AL3(MBBCCHHR+1),X'@CCW#CC',X'00',AL2(6) SEEK Cyl/Trk DC X'29',AL3(DSNAME),X'@CCW#CC',X'00',AL2(44) Search Key Equal DC X'08',AL3(*-8),X'@CSW#CC',X'00',AL2(0) TIC DC X'06',AL3(BUFFER),X'00',X'00',AL2(96) Read Data
If our channel program completes with normal status (Channel End+Device End) then we located and read the DSCB. If the DSCB was not located on the track we will receive Channel End + Device End + Unit Check and byte two of the Sense data will have the bit x’08’ set indicating record not found.
If the record is not found we can increment the track address (TT) and search again. We can continue to search track by track until we reach the end of the VTOC extent.
Actually, we can use the high-water mark in the Format 4 DSCB so we don’t need to search unused tracks. The field DS4HPCHR contains the highest address of a Format 1 DSCB in the VTOC (the high-water mark). Once we have searched the track indicated DS4HPCHR we can stop searching.