Easytrieve File Processing Overview

Nearly every production Easytrieve program reads files, writes files, or both. Payroll extracts arrive as sequential QSAM datasets; employee masters live in VSAM KSDS; audit trails append to GDG bases; printers receive formatted report lines. File processing in Easytrieve is the bridge between JCL DD allocation on the mainframe and the FIELD definitions your JOB logic uses. You declare files once in the Library with FILE, map record layouts with DEFINE, then drive I/O in JOB, PROGRAM, SORT, or SCREEN activities. Beginners who learned COBOL first often hunt for OPEN before every READ; Easytrieve opens files implicitly when automatic input starts or when the first GET, READ, PUT, or WRITE runs. This overview teaches the file lifecycle from declaration through read and write patterns, compares sequential versus keyed access, explains UPDATE and CREATE authority, and points you to focused pages on sequential files, VSAM, indexed KSDS, relative RRDS, and record maintenance. Master this chapter before writing complex multi-file jobs or keyed lookups.

Progress0 of 0 lessons

Where Files Live in the Program

Broadcom divides Easytrieve source into Environment, Library, and Activity sections. File processing starts in the Library immediately after optional PARM. Each FILE statement gives a unique file-name your program uses in I/O verbs. That name is not necessarily the DD name in JCL—SYSNAME and site conventions map logical names to operating-system identifiers. DEFINE statements under each FILE describe bytes inside the record: employee number, name, salary, dates. Activity sections consume those fields. A typical batch report declares FILE INPUT sequential, FILE OUTPUT sequential or printer, JOB INPUT INPUT to auto-read, and PRINT or PUT to emit results. Misplacing FILE in a REPORT block or Activity before Library causes compile errors that disappear once you respect section order from the program structure chapter.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
* Library — declare files and fields FILE PAYROLL FB(200 2000) FILE REPORT PRINTER DEFINE PAYROLL EMP-NO 9 1 EMP-NAME A 20 GROSS P 9.2 JOB INPUT PAYROLL IF GROSS GT 50000 PRINT 'HIGH EARNER' EMP-NO EMP-NAME GROSS END-IF

File Types at a Glance

Easytrieve FILE types and when to use them
FILE typeAccess styleTypical dataset
SEQUENTIAL (default)Forward sequential read; append on outputQSAM disk/tape, VSAM ESDS browse
INDEXEDKey-based READ, random and sequential by keyVSAM KSDS employee master
RELATIVERecord number (RRN) addressingVSAM RRDS slot table
SQLCursor-managed table rowsDB2 payroll table
PRINTER deviceFormatted report lines to SYSOUTDetail and summary listings

Omitting type defaults to sequential. Explicit SEQUENTIAL also enables FILE-STATUS for that file. INDEXED maps to VSAM KSDS on z/OS; RELATIVE maps to RRDS. Choosing the wrong type produces runtime ABENDs or silent wrong-record reads when JCL allocates a different organization than FILE declares. Match FILE type to DD DISP and AMP parameters your operations team documents.

Automatic Input Versus Controlled I/O

JOB INPUT file-name is the workhorse of batch Easytrieve. It tells the runtime to read the next record automatically at the start of each JOB iteration—equivalent to a hidden GET. Your IF, MOVE, PRINT, and PERFORM logic runs with a fresh input buffer each time. You cannot also GET the same file while it is automatic input; use JOB INPUT NULL on that file and explicit GET in a loop when you need custom control, or GET a secondary lookup file while the primary remains automatic. PROGRAM activities without JOB INPUT use GET or READ explicitly. SORT activities read and write work files the product manages. Understanding which pattern you use prevents the common error of testing EOF on a file that never received a manual GET.

Read patterns compared
PatternHow records arriveEOF handling
JOB INPUT MASTERAuto-read each iterationActivity ends when input exhausted
JOB INPUT NULL + GET MASTERYou issue GET inside logicYou test IF EOF MASTER
READ key on INDEXEDKeyed retrieval into bufferTest file presence / status

Record Formats: FB, VB, F, and V

Sequential QSAM files usually specify FB (fixed blocked), F (fixed unblocked), VB (variable blocked), or V (variable). FB(150 1800) means record length 150 and block size 1800—or FULLTRK on some releases for track-sized blocks. Variable formats need correct RDW handling; Easytrieve abstracts much of this when DEFINE lengths match the dataset. Wrong LRECL in FILE causes field misalignment: salary digits appear in name columns, totals go negative, and debugging takes hours. Always confirm BLKSIZE and LRECL with IDCAMS LISTCAT or IEBCOPY on the real dataset before coding DEFINE positions.

CREATE, UPDATE, and Output Files

CREATE on FILE allows building a new dataset when the JCL disposition permits. UPDATE authorizes changing existing records—mandatory for VSAM in-place maintenance and for SQL DELETE/INSERT paths. Output sequential files often use FILE OUTFILE FB(...) without UPDATE; the program PUT or WRITE appends new records. Printer files use the PRINTER device type so REPORT activities format headings and lines. VIRTUAL files hold intermediate data in memory or temp storage for multi-step jobs without permanent catalog entries. TABLE marks files used with SEARCH/LOOKUP for in-memory or external reference tables.

End-of-File and Status Checking

Automatic JOB INPUT ends the activity when the input file exhausts—your FINISH procedure runs on normal termination. Manual GET loops must test IF EOF file-name or IF NOT file-name before processing buffer fields. STATUS on GET or READ sets FILE-STATUS with the operating-system return code so you can branch on error without aborting the step. Constants like EOF in condition expressions are file-specific. Never assume the buffer is valid after a failed read; Broadcom documents that using fields after EOF without a guard produces unpredictable results.

JCL and DD Relationship

Easytrieve file-name is logical; JCL //DDNAME DD DSN=... allocates physical storage. Site standards often require file-name to match DD name for clarity, but SYSNAME can diverge when one program template serves multiple datasets. STEPLIB and SYSPRINT are product datasets, not business files. Confirm DISP=SHR for shared reads, DISP=OLD or NEW for updates, and AMP parameters for VSAM (AMP='AMORG=VSAM'). A mismatch between FILE INDEXED and a QSAM DD is a frequent beginner mistake caught only at execution.

Multi-File Job Designs

Production jobs combine input extract, master lookup, and error output. Pattern: JOB INPUT TRANSACTION as automatic input; FILE MASTER INDEXED for keyed READ inside BEFORE-LINE or job PROC; FILE ERRFILE SEQUENTIAL for rejected records via PUT. Secondary GET files must not be the automatic input file. Release documentation limits how many files stay open simultaneously; CLOSE files you finish early in long PROGRAM paths to free VSAM share locks. The multiple-files page in this chapter expands fan-in and fan-out designs.

File Processing Roadmap

  1. Declare FILE and DEFINE in Library — match type to dataset organization.
  2. Choose automatic JOB INPUT or controlled GET/READ loops.
  3. Add UPDATE or CREATE when changing data, not for read-only reports.
  4. Guard manual reads with EOF and optional STATUS.
  5. Align JCL DD with file-name and record format parameters.
  6. Study sequential, VSAM, indexed, and relative pages for depth on each access method.

Common Beginner Mistakes

  • FILE type does not match VSAM versus QSAM in JCL.
  • DEFINE positions wrong for actual LRECL.
  • GET on automatic JOB INPUT file in same activity.
  • Processing buffer after EOF without IF EOF test.
  • UPDATE omitted on VSAM master maintenance job.
  • Confusing Easytrieve file-name with COBOL SELECT name only in copybook.

Explain It Like I'm Five

File processing is like labeled boxes of cards your program can read and write. First you put stickers on each box saying what is inside—that is FILE and DEFINE. Then you decide whether the computer hands you one card automatically each turn (JOB INPUT) or you ask for a card when you are ready (GET). Some boxes are numbered in order; some have names on tabs to find one card fast; some use slot numbers. You must say please stop when the box is empty (EOF), and you need permission to change cards already in the box (UPDATE). JCL is the warehouse map telling the computer which real box each sticker points to.

Exercises

  1. Write Library FILE and DEFINE for a 80-byte FB input and a printer output.
  2. Convert JOB INPUT MASTER to JOB INPUT NULL with a GET loop and EOF test.
  3. List three differences between SEQUENTIAL and INDEXED FILE types.
  4. Sketch JCL DD statements for one input SHR and one output NEW sequential file.
  5. Explain when you need UPDATE on FILE for a VSAM salary change job.

Quiz

Test Your Knowledge

1. Where do you declare files in Easytrieve?

  • Library section FILE statements
  • REPORT TITLE only
  • JCL EXEC card
  • END-PROC block

2. Default FILE type when you omit the type keyword is:

  • Sequential
  • Indexed KSDS
  • SQL cursor
  • Printer only

3. Automatic JOB INPUT means:

  • Easytrieve reads the file each loop without explicit GET
  • Files never open
  • Only SYSPRINT is used
  • SQL FETCH only

4. UPDATE on FILE is required when you want to:

  • Change or delete existing records in update-capable files
  • Print headings only
  • Skip DEFINE
  • Ignore DD names

5. After manual GET you should test:

  • IF EOF file-name before using buffer fields
  • Only TITLE
  • Only MASK
  • Only SORT
Published
Read time18 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 FILE and data set processingSources: Broadcom Easytrieve 11.6 Language Reference FILE, GET, JOB, Data Set TypesApplies to: Easytrieve file processing on z/OS and compatible platforms