The JOB statement defines and initiates an Easytrieve processing activity—the heart of most batch programs. Inside a JOB you retrieve input, manipulate fields, PRINT reports, and write output. Optional INPUT identifies automatic sequential input: a file name, synchronized files with KEY fields, NULL to disable automatic reads, or SQL for automatic relational retrieval. Optional START and FINISH name procedures that run before the first record and after the last record. NAME labels the activity for documentation and EXECUTE. ENVIRONMENT and COMMIT control COBOL subprogram setup and recoverable work units on z/OS and transactional environments. If no PROGRAM activity exists, JOB and SORT activities run sequentially until a SCREEN activity appears. Beginners often treat JOB as “the program,” but a single Easytrieve source can contain multiple JOB activities, SORT steps, and screens. This page explains INPUT modes, defaults, synchronized matching, START and FINISH rules (including GOTO JOB behavior), and safe NULL-input loops.
12345678910111213141516JOB + [INPUT {file-name [KEY field...] | NULL | SQL | (file KEY ... file KEY ...)}] + [START start-proc-name] + [FINISH finish-proc-name] + [NAME job-name] + [ENVIRONMENT {NONE | COBOL}] + [COMMIT ([ACTIVITY|NOACTIVITY] [TERMINAL|NOTERMINAL])] * Simple automatic read: JOB INPUT PERSNL NAME SCAN-PERSONNEL-RECORDS * Synchronized match with FINISH: JOB NAME MATCH-FILES + INPUT (TRANFILE KEY TRAN-EMP-NO + MASTFILE KEY MAST-EMP-NO) + FINISH DISPLAY-EOJ-MESSAGE
Easytrieve programs typically order as Environment (PARM), Library (FILE, DEFINE), then Activities (JOB, SORT, SCREEN, PROGRAM). JOB activities contain logic statements, optional procedures, and REPORT declarations that PRINT feeds. PROGRAM or SCREEN can EXECUTE a named JOB. Without PROGRAM, activities execute in source order until SCREEN stops that automatic sequence.
| INPUT mode | Behavior | How activity ends |
|---|---|---|
| file-name | Automatic sequential GET of that Library file each iteration | After last automatic record (then FINISH if any) |
| (f1 KEY ... f2 KEY ...) | Synchronized multi-file matching on KEY fields | When synchronized input completes |
| NULL | No automatic input; you GET/READ yourself | Must STOP or TRANSFER |
| SQL | Automatic SQL rows; SELECT follows JOB immediately | When SQL result set exhausted |
| (omit INPUT) | Default prior SORT output or first Library file | Same as named automatic file |
File-name must be eligible for sequential input. Except in CICS, automatic input of a VSAM file with UPDATE on FILE issues GET HOLD so you can update the automatic input file in batch. IDMS and IMS/DLI files cannot use synchronized KEY matching.
If you code JOB without INPUT, Easytrieve still provides automatic input. If a SORT activity immediately preceded this JOB, the default input is the SORT output file—very handy for sort-then-report pipelines. Otherwise the default is the first file named in the Library section. Explicit INPUT is clearer for maintenance; rely on defaults only in short utilities.
Synchronized processing reads two or more files in key order, aligning matching and non-matching records so you can apply transactions to masters. Code KEY (field-name ...) for each file in the INPUT list. Key fields may be any fields from the file except varying-length, index, or subscript fields. IF MATCHED and related conditions tell you whether the current combination matched. Sorting inputs into key sequence before the JOB is your responsibility unless a prior SORT activity produced them.
START names a procedure executed during JOB initiation before the first automatic input record is retrieved. Typical work: set working-storage counters to zero (if not VALUE already), DISPLAY a banner, POINT an indexed file to a starting key. You cannot reference fields in automatic input files inside START—no record exists yet. If GOTO JOB runs inside START, START terminates and the JOB proceeds toward automatic input processing per GOTO rules.
12345678JOB INPUT PERSNL NAME MYPROG START INIT-PROC FINISH FINISH-PROC * body uses PERSNL fields PRINT RPT INIT-PROC. PROC TOT-AMT = 0 DISPLAY 'SCAN STARTING' END-PROC
FINISH runs after Easytrieve processes the last automatic input record during normal termination— ideal for grand totals and EOJ messages. If STOP EXECUTE runs in the JOB body, FINISH does not perform. GOTO JOB inside FINISH terminates FINISH early, so avoid skip branches there when you still need the totals DISPLAY.
NAME job-name documents the activity and identifies it on EXECUTE. Naming rules mirror other Easytrieve names: up to 128 characters, not all numeric, may start with letter, digit, or national character. Use meaningful names like MATCH-FILES or SCAN-PERSONNEL-RECORDS in production.
ENVIRONMENT(COBOL) establishes a COBOL subprogram environment before the JOB when CALL or FILE EXIT needs it; ENVIRONMENT(NONE) overrides a site default of COBOL. If the JOB has no CALL and no FILE EXIT, ENVIRONMENT(COBOL) is ignored. When a PROGRAM activity already activated ENVIRONMENT, that environment can remain active across an invoked JOB even if the JOB says NONE—see PROGRAM and subprogram documentation for your release.
COMMIT controls when recoverable work posts: ACTIVITY versus NOACTIVITY (default NOACTIVITY at activity end), and TERMINAL versus NOTERMINAL (default TERMINAL) for commits around terminal I/O in pseudo-conversational CICS style. Child activities inherit NOTERMINAL behavior when the parent specified NOTERMINAL. You can also issue explicit COMMIT and ROLLBACK statements for finer control.
123456789101112131415161718FILE PERSNL FB(150 1800) %PERSNL XMAS-BONUS W 4 P 2 VALUE 0 JOB INPUT PERSNL NAME MYPROG FINISH FINISH-PROC IF PAY-GROSS NOT NUMERIC DISPLAY EMP# ' DAMAGED' GOTO JOB END-IF XMAS-BONUS = PAY-GROSS * 1.03 PRINT MYREPORT FINISH-PROC. PROC DISPLAY 'EOJ' END-PROC REPORT MYREPORT LINE NAME-LAST XMAS-BONUS
Automatic input supplies each PERSNL record. GOTO JOB skips to the next person. PRINT queues report lines. FINISH runs once at the end. This is the canonical Easytrieve batch shape.
1234567JOB INPUT NULL NAME MANUAL-READ GET MASTER IF EOF MASTER STOP END-IF PERFORM PROCESS-REC GOTO JOB
Without STOP, NULL-input JOB never hits end-of-automatic-input. Always design an exit. Prefer named INPUT when one primary file drives the loop; use NULL when multiple GET paths or non-file drivers dominate.
JOB is the factory shift. INPUT says which conveyor belt brings boxes automatically. START is the morning setup before the first box. Each box gets worked on by the instructions in the middle. FINISH is sweeping the floor after the last box. INPUT NULL means there is no conveyor—you carry each box yourself with GET, and you must remember to stop when the room is empty.
1. JOB defines and initiates:
2. If you omit INPUT on JOB:
3. JOB INPUT NULL requires:
4. START procedure runs:
5. Synchronized file matching uses: