Easytrieve OPEN — File Open Lifecycle

COBOL programmers expect an explicit OPEN before READ or WRITE. Easytrieve beginners search the Language Reference for OPEN and often find CLOSE instead. Broadcom Easytrieve Report Generator 11.6 opens files implicitly: JOB activities with automatic input open files before the read loop; other files open on first I/O unless FILE DEFER delays them. This tutorial uses OPEN as the lifecycle topic name in the statements index because operations teams still describe when a dataset becomes available for processing. Understanding implicit open prevents mistakes with START procedures, SQL SELECT timing, TABLE external loads, and multi-pass FILE processing paired with CLOSE. This page teaches automatic JOB open sequence, DEFER semantics, processing mode detection, reopen after CLOSE, restrictions on automatic files, and JCL DD coordination at open time.

Progress0 of 0 lessons

Implicit Open — No OPEN Keyword

Easytrieve scans I/O statements in each activity and opens files with appropriate processing mode before executing them. You declare files in Library with FILE; activity logic references them with GET, READ, PUT, WRITE, or automatic JOB INPUT. The runtime issues open equivalent when needed. Legacy CA-Easytrieve Plus documentation sometimes discussed explicit open verbs; modern Report Generator centers on automatic behavior documented in File Processing Modes chapter.

Automatic JOB Input Open Sequence

text
1
2
JOB INPUT PERSNL NAME PAYROLL * record logic here

Broadcom documents implied execution: if START procedure exists, PERFORM it after open; retrieve input; on EOF run FINISH if present and wrap reports; else perform record logic and loop. Files required for automatic input and referenced outputs open before START runs. This is why INIT logic in START sees open files but must not READ automatic input file manually with GET.

Implied JOB INPUT steps (simplified)
StepAction
JOB beginsOpen files needed for activity
START PROCPERFORM if coded
Read loopAutomatic read until EOF
Per recordUser JOB logic executes
EOFFINISH PROC, report wrap, next activity

First I/O Open

Programs without JOB INPUT on a file still open that file when first GET, READ, PUT, or WRITE executes. Multi-file jobs mixing manual GET on secondary files open each file on its first use. Processing mode—input, output, update—derives from which verbs appear in the activity per File Processing Modes chapter.

FILE DEFER — Delay Open

text
1
2
3
4
5
6
FILE PERSNL SQL (PERSONNEL) DEFER JOB NAME RETRIEVE INPUT PERSNL START START-PROC START-PROC. PROC SELECT FROM PERSNL WHERE WORKDEPT = 921 END-PROC

Without DEFER, default SQL SELECT may open during initialization before START runs, then close and reopen when START issues SELECT—wasted work. DEFER delays open until SELECT in START executes. Apply same pattern when TABLE external load should follow working storage setup in START.

OPEN Versus CLOSE

CLOSE file-name ends access before activity ends. Next I/O on that file reopens it—functionally replacing explicit OPEN for multi-pass processing. Pair CLOSE with second pass GET or JOB INPUT restart patterns carefully; automatic input files cannot be CLOSE targets per CLOSE restrictions.

Files That Open Differently

  • Automatic input file—opened at JOB start; cannot CLOSE manually.
  • Automatic output—opened when first PUT or WRITE produces output.
  • Printer file—opened for SYSPRINT; cannot CLOSE per Language Reference.
  • SQL file—cursor open tied to SELECT; CLOSE resets cursor.
  • External TABLE—loaded at JOB initiation containing SEARCH.
  • Virtual work files—created on open; deleted on CLOSE without RETAIN.

VSAM and CREATE OPEN Errors

FILE CREATE and NOVERIFY parameters affect VSAM open behavior at implicit open time. RESET on CREATE reloads file; missing REUSE on occupied VSAM causes open error. Operations correct JCL DD allocation before rerunning—application logic rarely catches open failures unless file status fields are defined and tested after first I/O.

Processing Mode at Open

How product chooses mode at open
I/O verbs in activityTypical mode
GET onlyInput sequential
PUT onlyOutput
GET and WRITE UPDATEUpdate with browse
READ keyedDirect indexed access

FILE UPDATE parameter and verb mix must agree. Invalid combinations fail at compile or first open depending on checks. Document team standards for indexed update jobs to avoid opening for wrong access.

JCL and DD at Open Time

Open binds Library file-name to DD statement in JCL at runtime. Missing DD, wrong DSN, or DCB mismatch surfaces at open—not at compile. Developers test with production-like JCL classes. STEPLIB must resolve Easytrieve runtime before any file open in executed step.

INPUT NULL — Inhibit Automatic Input

text
1
2
3
JOB INPUT NULL NAME MANUAL-ONLY GET MYFILE * manual read loop logic

INPUT NULL prevents automatic read loop—you control all input with GET or READ. Open still occurs on first GET. Use when multiple input sources or complex browse patterns replace simple JOB INPUT sequential model.

Testing Open Behavior

  1. Trace START procedure side effects—confirm DEFER when SELECT lives in START.
  2. Run job with missing DD to document open error message for operations runbook.
  3. Verify external TABLE loaded before first SEARCH in JOB.
  4. Second pass after CLOSE—confirm reopen reads from beginning or POSITION as intended.
  5. SQL job—confirm only one cursor open after START SELECT with DEFER.

Common Open-Related Mistakes

  • Searching for OPEN keyword instead of understanding implicit open.
  • GET on automatic JOB INPUT file—invalid per Input chapter.
  • SQL SELECT in START without FILE DEFER—double open overhead.
  • Expecting CLOSE on automatic input file.
  • Wrong processing mode verbs for indexed UPDATE file.
  • Assuming file open at compile time—it is runtime with JCL.

Explain It Like I'm Five

Open is when the computer connects your program to the filing cabinet drawer. Easytrieve opens drawers automatically when you start reading or when the JOB begins—it does not make you say open out loud. DEFER is waiting to open the drawer until you actually reach for a file. CLOSE shuts the drawer early; next time you reach, it opens again. JCL is the list on the wall saying which drawer number belongs to your program today.

Exercises

  1. Diagram implied steps for JOB INPUT with START and FINISH procedures.
  2. Rewrite SQL example adding DEFER and explain why.
  3. List files that cannot be CLOSE targets and why.
  4. Describe reopen behavior after CLOSE before second GET pass.
  5. Document DD names your shop maps to a sample FILE statement.

Quiz

Test Your Knowledge

1. Easytrieve 11.6 typically opens files:

  • Automatically on JOB start or first I/O
  • Only via explicit OPEN keyword
  • In JCL EXEC only
  • At link-edit

2. FILE DEFER delays open until:

  • First input or output operation on that file
  • Program STOP
  • REPORT PRINT
  • MACRO expansion

3. JOB INPUT PERSNL implies before first record:

  • Open files and optionally PERFORM START procedure
  • CLOSE all files
  • Compile Library
  • SORT only

4. After CLOSE FILEA next GET on FILEA:

  • Reopens the file
  • Fails permanently
  • Deletes JCL
  • Ignores file

5. SQL FILE without DEFER before START PROC SELECT:

  • May open default SELECT twice causing extra processing
  • Always invalid
  • Skips compile
  • Opens printer
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 implicit file open and DEFERSources: Broadcom Easytrieve 11.6 Activity Input Output, FILE Statement DEFER, File Processing Modes, CLOSEApplies to: Easytrieve file open lifecycle