Monday, January 13, 2014

VSAM KSDS file generates file status code 46 when access mode is sequential

When an KSDS file uses Batch LSR buffering and the program opens the file with "ACCESS MODE IS SEQUENTIAL", then all READ operations against that file will generate file status code 46. Note that OPEN operation will go fine without any problem.

This is how Batch LSR buffering looks like in a DD statement

//MSTRFIL1 DD SUBSYS=(BLSR,'DDNAME=DDNEW','HBUFND=500','HBUFNI=100')
//MSTRFIL  DD DSN=MY.MSTR.FILE,DISP=SHR

Following is taken from batch LSR manual GC28-1672-01

3.5.2 Cases Where Batch LSR Cannot Be Used (Not Detectable by Subsystem)
There is another option which is incompatible with batch LSR that the subsystem does not check for because it is not indicated in the ACB:

Implied sequential positioning
     With NSR, opening a VSAM file for sequential input provides positioning to the beginning of the file. This does not occur for LSR.  If the subsystem is used to convert an application which relies on such positioning to use LSR, the first GET will receive an error indicating that an attempt was made to issue a request which requires positioning without having established a position. This is not detected by the subsystem because it is not detected until the actual GET request is issued.
 

NSR buffering can be used for VSAM files that are opened with "ACCESS MODE IS SEQUENTIAL". Below DD statement is an example of NSR buffering

//VSAMDD  DD DSN=MY.VSAM.FILE,DISP=SHR,AMP='BUFND=25'

BUFND is the number of data component buffers.

BUFND = (2 * number of CI's per track ) + 1 is usually a good number.

For JCL VSAM performance improvements in general use
Ø  BLSR for Direct (random) access
Ø  NSR for Sequential access