COBOL file status

File status 39: File attributes conflict with the program

File status 39 means OPEN found a conflict between the file's real attributes and what the program declares, such as record length, record format, key position or file organization. The OPEN fails.

Other names for this code

Also written as FS 39, file status code 39, COBOL status 39, VSAM status 39, file attribute mismatch COBOL, status key 39, SK39.

What it means

Status 39 is a permanent error from OPEN. The file exists and the mode is fine, but its fixed attributes don't agree with the program's SELECT and FD. IBM's list of attributes covers the organization, the prime and alternate keys, the code set, the maximum record size, the record type and the blocking factor.

For QSAM the usual problems are record length and format. With fixed-length (F or FB) records, the FD record length must equal the data set's LRECL. With variable-length (V or VB) records, the largest FD record must be 4 bytes less than LRECL, because LRECL includes the 4-byte record descriptor word. A RECORDING MODE of F against a V data set, or the reverse, also gives 39. Printer files may need one extra byte in LRECL for the carriage control character, depending on the ADV compiler option.

For VSAM, COBOL compares the RECORD KEY and ALTERNATE RECORD KEY clauses with the key lengths and positions in the catalog, and the FD's record size with the cluster's. A file described as QSAM whose DD points at a VSAM cluster also fails with 39. These checks are made by COBOL after the access method has opened the file, so data-name-8 usually holds no VSAM error code.

Common causes

  • The copybook changed length and the program was recompiled, but the data set wasn't rebuilt, or the other way round.
  • A variable-length FD whose largest record equals LRECL, forgetting the 4-byte RDW.
  • RECORDING MODE F in the program for a RECFM=VB data set, or the reverse.
  • The cluster's KEYS(length offset) doesn't match the length and position of the RECORD KEY field in the record.
  • The ALTERNATE RECORD KEY clauses don't match the alternate indexes defined over the cluster.
  • The DD points at a VSAM cluster for a file the program describes as sequential.

How to find the problem

  1. Look in the job log for the IGZ warning issued with the 39. IGZ0201W gives both record lengths. IGZ0200W covers a QSAM file pointed at a VSAM data set, IGZ0202W and IGZ0203W cover ASCII mismatches, and IGZ0204W covers RECORDING MODE.
  2. For QSAM, check RECFM, LRECL and BLKSIZE in ISPF option 3.4 and compare them with the FD record length in the compiler listing.
  3. For VSAM, run IDCAMS LISTCAT ALL and compare KEYLEN, RKP and MAXLRECL with the program's key and record definitions. Check each alternate index too.
  4. If there's no FILE STATUS clause, IGZ0035S follows the warning and the program ends with U4038.

How to fix it

  • Make the FD and the data set agree. For a QSAM FB file, the FD record length equals LRECL. For VB, the largest record is LRECL minus 4.
  • Code BLOCK CONTAINS 0 RECORDS in the FD so the block size comes from the data set or the system, not from the program.
  • For VSAM, redefine the cluster with the right KEYS and RECORDSIZE, or correct the key clauses, then recompile every program that uses the file.
  • Point the DD at the right data set if a VSAM cluster and a sequential file have similar names.

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

Why does my VB file give 39 when the lengths look right?

LRECL for a variable-length file includes the 4-byte record descriptor word. The largest record in the FD must be LRECL minus 4.

Does a 39 come with a VSAM return code?

Usually not. VSAM opened the file without complaint, and COBOL found the conflict afterwards by comparing attributes, so look at the IGZ message and LISTCAT instead.

What is the difference between 39 and 04?

39 stops the OPEN because a fixed attribute conflicts. 04 is a warning on one READ whose record length is outside the FD's range.