VSAM file status code

VSAM file status code indicates the status of the operation. VSAM files require at least one data record to be initially loaded into the file before the file could be opened for input or update processing. This is because VSAM issues a VERIFY command upon opening a file to reset the end-of-file pointer. If the file has never been loaded, the VERIFY fails because the high used RBA (Relative Byte Address) (HI-USEDRBA) is still zero. Therefore, VSAM files must be initially “loaded” to set the HI-USED-RBA to a value other than zero. This is done by writing a record to the VSAM file in “load” mode and optionally deleting the record to empty the file while leaving the HI-USED-RBA at a non-zero value.

A VSAM file that has never contained a record is treated as unavailable. Attempting to open for input will fail. An empty file can be opened for output only. When you open for output, COBOL will write a dummy record to the file & then delete it out.

VSAM distinguishes between an empty data set (that is, one that has never had a record in it) and a data set with no records (for example, adding a record to a KSDS and then deleting it). The difference is that for each write to a VSAM data set, a pointer is updated to reflect the highest used RBA. If you have never written any data to the data set, this pointer has no value and hence causes VSAM problems when attempting to use it to locate the end of the used data. Any program attempting to open a VSAM data set for input before anything has been written to the data set will have a problem & amend will happen with return code 35 as VSAM is unavailable.

Initializing VSAM File Status (Program)

  • To initialize the VSAM, you can open it once in output mode and close it in the program during initialization, it could solve your problem. After that again open it in I/o mode.
  • Write a step in JCL that delete defines VSAM and REPRO some records from a flat-file Say GDG version this step should be executed before the program uses VSAM.

Initializing VSAM File Status (Manually)

  • Open the VSAM file in EDIT mode in File Manager.
  • Insert any record in the VSAM file and save.
  • Delete that record & save it will initialize the VSAM file.

Example

 //STEP010 EXEC PGM=IDCAMS
 //SYSPRINT DD SYSOUT=*
 //SYSOUT   DD SYSOUT=*
 //SYSIN    DD *
  DELETE  XXXXX.TEST.VSAM        PURGE CLUSTER   
  DEFINE CLUSTER(NAME(XXXXX.TEST.VSAM)          - 
                VOLUME(* *)                     -  
                UNIQUE                          -   
                SHAREOPTIONS(3 3)               - 
                CYLINDERS(7 7))                 - 
              DATA (NAME(XXXXX.TEST.VSAM.DATA)  -    
                KEYS (29 0)                     - 
                RECORDSIZE(35 35)               - 
                CISZ(4096))                     -   
             INDEX (NAME(XXXXX.TEST.VSAM.INDEX) - 
                NOIMBED NOREPLICATE)   
 /*
 //STEP020  EXEC PGM=IDCAMS       
 //IN   DD  DSN=XXXXX.TEST.PS,DISP=SHR      
 //OUT  DD  DSN=XXXXX.TEST.VSAM,DISP=SHR   
 //SYSOUT   DD  SYSOUT=*    
 //SYSPRINT DD  SYSOUT=*          
 //SYSIN    DD  *
   REPRO INFILE(INF) OUTFILE(OUTF) COUNT(1)
 /* 

VSAM File Status

File StatusDescription
00SUCCESSFUL COMPLETION
02DUPLICATE KEY, NON-UNIQUE ALT INDEX
04READ, WRONG LENGTH RECORD 
05OPEN, FILE NOT PRESENT
07CLOSE with REEL or NO REWIND executed for non tape dataset.
10END OF FILE
13File Not Found
14Attempted to READ a relative record outside file boundary
16Accessing VSAM file Error
19Accessing VSAM file Error
20INVALID KEY VSAM KSDS OR RRDS
21SEQUENCE ERROR, ON WRITE OR CHANGING KEY ON REWRITE
22DUPLICATE KEY
23RECORD NOT FOUND or FILE NOT FOUND
24Invalid Key – key outside boundary of file.
28Unable to extend the dataset
30Permanent I/O Error
34Permanent I/O Error – Record outside file boundary
35OPEN, FILE NOT PRESENT
37Open file error due to opening mode
38Tried to OPEN a LOCKed file
39LOGIC ERROR
41OPENING A FILE THAT IS ALREADY OPENED 
42CLOSING A FILE WITHOUT OPEN
43DELETE OR REWRITE & NO GOOD READ FIRST
44Tried to REWRITE a record of a different length
46SEQUENTIAL READ WITHOUT POSITIONING
47READING FILE NOT OPEN AS INPUT/IO/EXTEND
48WRITE WITHOUT OPEN IN IO MODE
49DELETE OR REWRITE WITHOUT OPEN IN IO MODE
90Unsuccessful OPEN, READ, WRITE or CLOSE operation
91Password or authorization failed
92LOGIC ERROR / OPENING A OPEN FILE  / READING OUTPUT FILE  / WRITING INTO A INPUT FILE  / DEL or REW BUT NO PRIOR READ
93OPENING A FILE THAT IS ALREADY OPENED 
94SEQUENTIAL READ AFTER END OF FILE / NO CURRENT REC POINTER FOR SEQ
95File Information invalid or incomplete
96MISSING DD STATEMENT IN JCL
97OPEN OK, FILE INTEGRITY VERIFIED
98The file is Locked – OPEN failed
99Record Locked – record access failed
100Improper loading  
160Input file might be empty
168The device type is not supported

VSAM File Status Resolution

VSAM return code 00        – SUCCESSFUL COMPLETION

Root Cause:

  • The Length of the record does not match the properties or attributes defined for the length of the file. 
  • The file is a Variable Length block file but you defined a fixed-length block in your FD clause. Most of the time, this error occurs while reading from a  file or writing to a file.

Fix:

  • Assign the proper record length of your  file in the DCB Parameter and match it with the length provided in the FD clause of your COBOL Program.

VSAM return code 04 – READ, WRONG LENGTH RECORD 

Root Cause: The logical error in the program

Fix: The Logic of the COBOL Program itself is wrong so you need to correct the logic of the program.

VSAM return code 13 – File Not Found

Root Cause: File Not Found

Fix: Provide the correct details of the file name. Check if the path of your VSAM file is correct.

VSAM return code 16 – Accessing VSAM file Error

Root Cause: It depends on the type of file, the program used to access the VSAM file and is mostly related to accessing 

Fix: Fix will be based on the way you are accessing the file from a program. Are you trying to update a  file for which you do not have permission?

VSAM return code 19 – Accessing VSAM file Error

Root Cause: In case you are accessing the VSAM file in CICS and you did not provide a proper entry of the  file

Fix: Check if the PCT entry of the file is proper.

VSAM return code 20 – INVALID KEY VSAM KSDS OR RRDS

Root Cause: In the case of  KSDS or RRDS, the key is an INVALID KEY

Fix: Correct the KEY. Check the position, definition, etc and correct it.

VSAM return code 22 – DUPLICATE KEY

Root Cause: Duplicate key defined for  Indexed or relative Files. Duplicate alternate key but the alternate key is defined as unique.

Fix: Remove the duplicate entry of the key.

VSAM return code 23 – RECORD NOT FOUND or FILE NOT FOUND

Root Cause: The record is not found when you are trying to access using a key. File not found.

Fix: Check if the record is correct or the path to access the file is given correctly.

VSAM return code 24 – Invalid Key – key outside the boundary of file.

Root Cause: Trying to write beyond the boundary in case of Relative and indexed files using the key. The size of the Relative Record number is larger.

Fix: Do not write beyond the boundary or change the boundary.

VSAM return code 28 – Unable to extend the dataset

Root Cause:

  • The primary space is already exhausted and the space in Secondary space cannot be extended further due to the limitation in space.
  • The Index CI is not large enough

Fix: Check with your storage group or try to give less value to your secondary allocation.

VSAM return code 35 – OPEN, FILE NOT PRESENT

Root Cause: You are trying to open a file that is not present.

Fix:

  • Check why the file is not present? Are you providing the correct filename with the correct path?
  • Initialize the file using any of the above method.

VSAM return code 37 – Open file error due to opening mode

Root Cause: You are trying to open a  file in a particular mode that is not allowed for that file.

Fix: Check the file opening modes available for the file and fix it.

VSAM return code 39 – LOGIC ERROR 

Root Cause:

  • The Unsuccessful opening of a  file due to the conflicting attributes of the file.
  • Wrong value in DCB which is not matching the file attributes in the Program.

Fix: Check the file attribute in the actual file, the file attributes defined in the FD section of the program,  the record length in your DCB Parameter and the record mode, etc.

VSAM return code 41 – OPENING A FILE THAT IS ALREADY OPENED 

Root Cause: You are trying to open a  file in a particular mode that is not allowed for that file.

Fix: Check the file opening modes available for the file and fix it.

VSAM return code 42 – CLOSING A FILE WITHOUT OPEN. 

Root Cause: When the file is already closed and you try to do a CLOSE operation once again on the file which is already closed.

Fix: Change the program to make sure that you do not give a CLOSE file on the file which is already closed.

VSAM return code 46 – SEQUENTIAL READ WITHOUT POSITIONING

Root Cause: If you try to sequentially read a  file even when the end of the record is reached.

Fix: Once the End of the File is reached, do not read the file.

VSAM return code 47 – READING FILE NOT OPEN AS INPUT/IO/EXTEND

Root Cause: File not opened in INPUT or I-O mode.

Fix: Open the file in INPUT or I-O mode.

VSAM return code 90 – Unsuccessful OPEN, READ, WRITE or CLOSE operation

Root Cause:

  • Unsuccessful OPEN, READ, WRITE or CLOSE operation.
  • You defined ‘LINE SEQUENTIAL’ for  file
  • You missed to initialize the  file before OPEN, READ or WRITE statement.
  • If you are trying to open an empty file or a file which does not exist and you have not tried to capture the return code of the OPEN or READ or WRITE, then you can get this generic error.
  • There can be other reason for status code 90 as well as this error is not a specific rather a generic error.

Fix:

  • If you have coded ‘LINE SEQUENTIAL’ then remove it.
  • Code the file status for OPEN, READ, WRITE or CLOSE operation and see where you are getting the error so that you can easily fix that.

VSAM return code 91 – Password or authorization failed

Root Cause: Password Failure. Authorization failure.

Fix: Check the password which is given for VSAM file or whether you are authorized to access the file or not?

VSAM return code 92 – LOGIC ERROR / OPENING A OPEN FILE  / READING OUTPUT FILE  / WRITING INTO A INPUT FILE  / DEL or REW BUT NO PRIOR READ

Root Cause:

  • Logic error.
  • Common logic errors are like a wrong way of Opening the file, improper way of reading the  file or Writing the  file.

Fix:

  • Check the logic of the program mentioned above and fix it.
  • The most common status code 92 is ‘VSAM file status 92 while writing’ and you need to fix the logical error related to write or rewrite. Check if the file is opened correctly for writing

VSAM return code 93 – OPENING A FILE THAT IS ALREADY OPENED 

Root Cause:

  • Resource not available.
  • Storage is insufficient for 
  • Extents used up and extra extents not available

Fix: Check with your storage group.

VSAM return code 96 – MISSING DD STATEMENT IN JCL 

Root Cause: Missing DD statement for the VSAM or QSAM file.

Fix: Code the missing DD statement in the JCL

VSAM return code 97 – OPEN OK, FILE INTEGRITY VERIFIED

Root Cause: OPEN file successful and the file integrity verified. This might happen when a previous Job did not close the  file so VSAM has to verify the integrity of the file.

Fix: Check the file opening modes available for the file and fix it.

VSAM return code 100 – Improper loading  

Root Cause:

  • Improper loading of  file.
  • Loading of a cluster using REPRO failed.

Fix: Before building the alternate index(AIX) and path, you need to load the cluster.

VSAM return code 160 – input file might be empty

Root Cause: The input file might be empty when you try to open it.

Fix: Check with your storage group.

VSAM return code 168 –  The device type is not supported

Root Cause: The device type is not supported.

Fix: Check with your admin.

1. During the processing of a VSAM file, some system error occurs and it is subsequently unusable how to fix this issue?

Answer: Run VERIFY

2. How do you fix the problem associated with VSAM file status out of space condition?

Answer:

  • Define new VSAM dataset allocated with more space.
  • Use IDCAMS to REPRO the old VSAM file to the new VSAM dataset.
  • Use IDCAMS to ALTER/rename the old VSAM dataset or use IDCAMS to DELETE the old VSAM dataset.
  • Use IDCAMS to ALTER/rename the new VSAM dataset to the name of the original VSAM dataset.

VSAM Interview Questions : Click Here. IBM Reference : Click Here

Scroll to Top