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.
1234567891011121314FILE 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.
123456789101112JOB 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.
| Role | How Easytrieve reads | Example |
|---|---|---|
| Primary drive | JOB INPUT file-name automatic loop | Daily transaction extract |
| Lookup master | READ or GET per primary row | INDEXED employee master |
| Output detail | PUT when business rules pass | RPTOUT sequential |
| Error / audit | PUT on validation failure | ERRFILE or ERRPRINT PRINTER |
| Work in progress | PUT then SORT on VIRTUAL | SORTWRK VIRTUAL |
| Static reference | SEARCH TABLE once or GET at start | CODE-TABLE TABLE |
12345678910111213141516FILE 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.
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.
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.
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.
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.
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.
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.
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.
1. A file used as automatic JOB INPUT cannot also be:
2. Typical pattern: transactions JOB INPUT, master file:
3. JOB INPUT NULL is used when:
4. Each FILE in a program needs:
5. FILE DEFER on a secondary file: