COBOL

COBOL File Status 39: Trace Dataset Attributes Before Changing the FD or Program

`FILE STATUS 39` at `OPEN` often means the program and the allocated dataset disagree about record attributes. This incident guide shows how to prove which attributes differ, separate a deployment or JCL issue from a layout change, and avoid a risky “fix” that merely lets the job run against the wrong file.

InputValidationProcessingOutput
Original DBala learning flow — a visual summary of this article’s practical decision path.

FILE STATUS 39 at OPEN often means the program and the allocated dataset disagree about record attributes. This incident guide shows how to prove which attributes differ, separate a deployment or JCL issue from a layout change, and avoid a risky “fix” that merely lets the job run against the wrong file.

The example names and values are fictional. Compiler options, record formats, storage rules, and support procedures vary by installation. Do not change an FD, copybook, JCL DCB, or production dataset definition until the actual allocation and the interface contract have been reviewed.

Symptom: the program fails before it processes a record

A nightly import program opens INVOICE-IN and stops with a message showing file status 39. No business record has been validated; the failure happens while COBOL is matching the file description to the dataset it received.

Status 39 is commonly associated with an inconsistency between the COBOL file description and the external file attributes. It is not a reliable diagnosis by itself. A program can be correct for its intended interface and still receive the wrong dataset. Conversely, JCL can allocate the expected name while the producer has changed the physical record format or length.

Treat the open failure as a contract check. The two sides of that contract are:

| Side | Evidence to collect | Question to answer |
|---|---|---|
| COBOL program | active load module, source/copybook level, FD, compiler listing if available | What does this executable expect? |
| Allocated dataset | resolved DSN, allocation messages, catalog or approved dataset-display attributes | What did this job actually open? |
| Interface control | feed header/version, delivery note, generation identity, change record | Was this the intended file for this run? |

A similar dataset name is not sufficient proof. A cycle-specific input can have the right business date but come from a test flow, an older layout, or an unexpected generation.

Diagnosis path: compare facts in a fixed order

First preserve the job ID, step name, return code or abend, application message, and relevant JES allocation output. Capture the DD name and the fully resolved dataset name, including the absolute generation when GDGs are involved. Do not rely only on a relative reference such as (+0) after the run.

Next identify the file attributes that matter to the application. For a sequential file, start with record format and logical record length. Block size can also be relevant to allocation and performance, but it is usually not the first business-layout question. For variable records, distinguish the maximum logical record length from the length of one sample record. For spanned records, blocked formats, and product-managed files, use site documentation rather than assuming the simple case applies.

Then read the FD that belongs to the executable that ran—not an unverified source member with a matching program name. A simplified fixed-format input might be defined as follows:

       SELECT INVOICE-IN ASSIGN TO INVOICEIN
           ORGANIZATION IS SEQUENTIAL
           FILE STATUS IS WS-INVOICE-STATUS.

FD INVOICE-IN
RECORDING MODE IS F
RECORD CONTAINS 120 CHARACTERS.
01 INVOICE-RECORD PIC X(120).
```

That definition expresses an expectation of fixed, 120-character logical records. If approved dataset information shows RECFM=VB,LRECL=256, the mismatch is real even if a viewed sample appears to contain 120 printable business characters. Variable blocked records carry record-descriptor information, and their maximum length represents a different physical agreement from FB,LRECL=120.

A compact evidence comparison is more useful than changing either side immediately:

| Attribute | Program expectation | Allocated dataset | Interpretation |
|---|---|---|---|
| Record format | FB | FB | compatible on this attribute |
| Logical record length | 120 | 120 | compatible on this attribute |
| Dataset identity | inbound daily feed | previous-cycle exception file | stop: wrong input despite matching DCB |
| Layout version | version 3 copybook | version 4 sender header | investigate layout and ownership |

The third and fourth rows matter because correcting an attribute mismatch is not the same as proving that the data is appropriate. An interface can be physically openable while semantically wrong.

Worked example: a JCL override silently changes the input contract

Suppose a program was tested with a fixed-length export. The scheduled job invokes a PROC, and an in-stream override points INVOICEIN to a newly delivered variable-length file:

//LOADINV  EXEC PGM=INVOICEBT
//INVOICEIN DD DSN=ACME.ARCHIVE.INVOICE.D20261114,
//             DISP=SHR
//SYSOUT    DD SYSOUT=*

The JCL itself has no DCB parameters, which is normal when an existing dataset supplies its own attributes. The support question is therefore not “which DCB should we add?” It is “why did this DD resolve to this dataset, and is it the contracted input?”

If its approved attributes show VB and maximum length 256 while the active FD expects FB and 120, adding DCB=(RECFM=FB,LRECL=120) to an existing DISP=SHR input is not a safe conversion. It may be ignored, conflict with the allocation, or encourage someone to treat incompatible records as compatible. The corrective path depends on the evidence:

Do not infer the producer layout solely from DCB values. FB,LRECL=120 says how records are physically presented, not whether bytes 1–10 still contain the same business field. Check the version or control record and the agreed layout specification too.

What to verify before a rerun

Safe correction and restart decision

A rerun is reasonable only after the intended dataset and compatible contract have been demonstrated, and after normal restart checks show that prior work will not be duplicated. If the issue is a wrong DD target and no business processing occurred in the failed step, a corrected controlled submission may be small. If the file layout changed or an earlier step produced side effects, recovery scope needs an application-owner decision.

The practical lesson is simple: file status 39 is evidence of a mismatch, not an instruction to edit the COBOL definition. Establish the executable expectation, the actual allocated attributes, and the interface identity first; then correct the layer that introduced the difference.

← Back to all articles