Easytrieve Multiple Files Processing

Real Easytrieve jobs rarely touch one dataset. A payroll run reads a transaction ESDS as the driving file, looks up each employee on an INDEXED KSDS master, writes exceptions to an output sequential file, and logs errors to a PRINTER file—four FILE declarations, four DD names, one coordinated flow. Beginners fail multi-file programs by making two files automatic JOB INPUT, by GET on the primary input file, or by forgetting EOF on secondary GET loops. The language enforces one automatic input stream per JOB activity; everything else is secondary I/O you orchestrate with GET, READ, PUT, and procedures. JOB INPUT NULL frees you to GET multiple files in custom order for match-merge style logic. FILE DEFER staggers opens when a file is not needed until mid-program. This page teaches primary versus secondary roles, lookup by READ on INDEXED masters, TABLE SEARCH as a multi-source alternative, output and error files, multi-activity file handoff with VIRTUAL RETAIN, organization mix ESDS plus KSDS plus RRDS, and testing strategies that prove each file path executed.

Progress0 of 0 lessons

FILE Declarations for Each Dataset

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
FILE TRANS SEQUENTIAL FB(80 800) TXN-EMP-NO 1 9 N TXN-AMT 10 5 P 2 FILE EMPMAST INDEXED UPDATE FB(200 2000) EMP-NO 1 9 N EMP-NAME 10 30 A EMP-DEPT 40 3 A FILE ERRFILE SEQUENTIAL FB(80 800) ERR-REC 1 80 A FILE RPTOUT SEQUENTIAL FB(120 1200) OUT-LINE 1 120 A

Four unique file-names: TRANS drive file, EMPMAST KSDS master, ERRFILE sequential exceptions, RPTOUT successful output. Each needs a JCL DD with matching name (unless SYSNAME maps externally). Field layouts are independent per FILE. UPDATE on EMPMAST if the job rewrites master balances; omit UPDATE on read-only inquiry. PRINTER SYSPRINT is separate from these user files.

Primary JOB INPUT Pattern

text
1
2
3
4
5
6
7
8
9
10
11
12
JOB INPUT TRANS MOVE TXN-EMP-NO TO EMP-NO READ EMPMAST IF EMPMAST-PRESENCE ADD TXN-AMT TO EMP-GROSS WRITE EMPMAST MOVE DETAIL-LINE TO OUT-LINE PUT RPTOUT ELSE MOVE ERROR-LINE TO ERR-REC PUT ERRFILE END-IF

TRANS is automatic input—Easytrieve GETs each transaction without explicit GET in source. Each iteration READs EMPMAST by key in EMP-NO moved from TXN-EMP-NO. Success path WRITEs master and PUTs RPTOUT; failure PUTs ERRFILE. Three files touched per row besides TRANS. You cannot code GET TRANS inside this loop. Secondary READ does not advance TRANS—only automatic input does.

Primary Versus Secondary Roles

Multi-file responsibilities
RoleHow Easytrieve readsExample
Primary driveJOB INPUT file-name automatic loopDaily transaction extract
Lookup masterREAD or GET per primary rowINDEXED employee master
Output detailPUT when business rules passRPTOUT sequential
Error / auditPUT on validation failureERRFILE or ERRPRINT PRINTER
Work in progressPUT then SORT on VIRTUALSORTWRK VIRTUAL
Static referenceSEARCH TABLE once or GET at startCODE-TABLE TABLE

JOB INPUT NULL and Controlled Multi-GET

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
FILE FILEA SEQUENTIAL FILE FILEB SEQUENTIAL JOB INPUT NULL NAME MERGE MERGE. PROC GET FILEA IF EOF FILEA STOP END-IF GET FILEB IF EOF FILEB STOP END-IF * compare keys and process match logic END-PROC

When neither file should be automatic input—balanced merge, interleaved read, or programmer-controlled pacing—use JOB INPUT NULL and GET both files inside a procedure. Test EOF on each GET independently. Match-merge requires comparing key fields from both buffers before advancing the lagging file. This pattern is advanced for beginners but essential when two sequential ESDS files must be walked together without SORT first.

Mixing Organizations

ESDS TRANS plus INDEXED EMPMAST is the classic pair. ESDS plus RRDS slot table plus KSDS master appears in rating applications. Each organization uses correct FILE type: SEQUENTIAL, INDEXED, RELATIVE. JCL DD must point at matching catalog object. Do not READ keyed on ESDS; use INDEXED FILE for master. Sequential browse on multiple ESDS files means one JOB INPUT and secondary GET on the other with JOB INPUT NULL, or two-pass JOB with VIRTUAL intermediate.

TABLE SEARCH as Second Source

FILE DEPT-TABLE TABLE INSTREAM or external max-entries loads department names once. JOB INPUT TRANS uses SEARCH DEPT-TABLE instead of disk READ on a second master—reduces I/O when reference data is small. TABLE is still a FILE declaration but not sequential GET per row. Combine TABLE with INDEXED when static codes are in TABLE and volatile balances are on KSDS.

FILE DEFER and Open Order

DEFER on EMPMAST delays open until first READ—saves open cost when early transactions might exit on header validation before any lookup. DEFER on SQL files pairs with SELECT in START procedure. Default opens all non-DEFER files at activity start. Multi-file jobs with many DDs may hit open failures if one DD is missing—DEFER limits failure to first use, easing debugging.

Output Files and Automatic JOB Output

Besides explicit PUT RPTOUT, REPORT activities may target PRINTER files. Only one automatic output pattern per activity type applies—consult JOB and REPORT chapters. Multiple PUT files are fine in one JOB loop. Ensure SPACE and DISP on each output DD in JCL. ERRFILE and RPTOUT may both be GDG (+1) with different bases.

Multi-Activity Handoff

Activity one JOB INPUT TRANS PUT to SORTWRK VIRTUAL RETAIN. Activity two JOB SORT or JOB INPUT SORTWRK REPORT. CLOSE between activities on non-RETAIN files. RETAIN virtual work connects phases without cataloged temporaries. Production jobs separate compile/link/exec steps—not activities—but within one Easytrieve program, activities sequence file lifecycle.

CICS and Online Multi-File

Screen programs GET master files in BEFORE-SCREEN while SCREEN activity handles terminal I/O—another multi-file shape. Batch rules on automatic JOB INPUT do not apply; screen procedures use GET and READ with CICS-specific HOLD guidance. Keep batch multi-file tutorials separate from online WHEN learning paths.

Common Multi-File Mistakes

  • GET on automatic JOB INPUT file.
  • Two JOB INPUT files in one activity.
  • READ master without moving key from primary buffer.
  • Same file-name twice in FILE statements.
  • EOF tested on primary only while secondary GET runs past end.
  • INDEXED master declared SEQUENTIAL.

Testing Multi-File Programs

  1. Run with empty TRANS—verify zero PUTs, clean EOF.
  2. One txn with bad key—ERRFILE receives row, RPTOUT does not.
  3. One txn with good key—master updates and RPTOUT PUT.
  4. SYSPRINT record counts per file when DISPLAY counters coded.
  5. Remove one DD—confirm DEFER delays ABEND until first use if applicable.

Explain It Like I'm Five

Multiple files are several boxes of cards. One box is the line you must deal with one card at a time—that is JOB INPUT. When you pick a card from the line box, you look up the same number in a big catalog box (READ on master). You put answer cards in the good pile (PUT output) or the mistake pile (ERRFILE). You cannot have two line boxes both moving automatically—you hold one line and manually pull from the other when you use JOB INPUT NULL.

Exercises

  1. Declare TRANS, INDEXED MASTER, OUT, ERR; write JOB INPUT lookup loop.
  2. Sketch JOB INPUT NULL merge pseudocode for two sequential files.
  3. Add TABLE SEARCH replacing small master READ.
  4. List JCL DD names required for four FILE declarations.
  5. Document EOF tests needed for primary and secondary in NULL job.

Quiz

Test Your Knowledge

1. A file used as automatic JOB INPUT cannot also be:

  • GET in the same activity without JOB INPUT NULL
  • Referenced in FILE
  • Used in REPORT
  • Closed

2. Typical pattern: transactions JOB INPUT, master file:

  • GET or READ by key inside the loop
  • Second JOB INPUT automatic
  • SQL only
  • PRINTER

3. JOB INPUT NULL is used when:

  • You control all reads with GET/READ in procedures
  • You want two automatic inputs
  • You skip Library
  • You delete JCL

4. Each FILE in a program needs:

  • Unique file-name and usually matching JCL DD
  • Same name as STEPLIB
  • Only one per job
  • SQL keyword

5. FILE DEFER on a secondary file:

  • Delays open until first I/O on that file
  • Deletes the file
  • Makes it automatic input
  • Opens at compile
Published
Read time19 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 multi-file JOB INPUT GET READ patternsSources: Broadcom Easytrieve 11.6 Language Reference JOB, GET, FILE, Activity Input and OutputApplies to: Easytrieve programs with multiple FILE declarations