COBOL file status

File status 37: OPEN mode not supported by the file

File status 37 means the program opened a file in a mode the file can't support, such as OPEN OUTPUT on input-only data or OPEN I-O on a device that can't update in place. The OPEN fails.

Other names for this code

Also written as FS 37, file status code 37, COBOL status 37, status key 37, COBOL OPEN mode error, SK37.

What it means

Status 37 is a permanent error from OPEN. The file exists and is allocated, but the open mode doesn't match what the file can do. IBM lists three cases. OPEN OUTPUT or EXTEND on a file that can't be written. OPEN I-O on a file that doesn't support both reading and writing. OPEN INPUT on a file that can't be read.

It mostly concerns QSAM files, because the DD decides what the file can do. Updating records in place with OPEN I-O and REWRITE needs a direct access device, so a QSAM file on tape can't be opened I-O. In-stream data (DD *) can only be read and a SYSOUT data set can only be written, so opening one of them the other way round can also end in 37.

Under the older CMPR2 behavior these cases were reported as 90, so old programs that test for 90 may miss a 37. If the program has no FILE STATUS clause and no error declarative, the runtime issues IGZ0035S and the program ends with abend U4038.

Common causes

  • OPEN I-O on a QSAM file on tape, or on another device that can't rewrite records in place.
  • Opening in-stream data (DD * or DD DATA) for OUTPUT or EXTEND, or a SYSOUT data set for INPUT. These only work in one direction, and the OPEN fails, often with 37.
  • The program's open mode was changed, for example from INPUT to I-O to add an update, without changing the JCL.

How to find the problem

  1. DISPLAY the status after OPEN, or read the IGZ0035S message, which names the file.
  2. Look at the DD for that ddname in the JESJCL listing. Note whether it's DD *, SYSOUT, a tape or a disk data set.
  3. Find the OPEN statement in the program and the mode it uses.

How to fix it

  • Match the mode to the device. Use a disk data set for files that need OPEN I-O.
  • Write reports and work output to SYSOUT or a data set, and read control cards from DD *, not the other way round.
  • If a program has to update a tape file, copy it to disk, update it there, and copy it back.
  • Add a FILE STATUS clause and check it after OPEN, so a 37 is reported with the file name.

IBM documentation

IBM Enterprise COBOL documentation. Use the documentation for your installed release.

This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.

Report a correction to WND Software.

Questions

What is the difference between file status 35 and 37?

35 means the file isn't there. 37 means the file is there but can't be used in the mode the program asked for.

Why did 37 start appearing after we dropped CMPR2?

Under CMPR2 these OPEN failures were reported as 90. Enterprise COBOL reports them as 37, so status checks written for 90 need updating.