Easytrieve JOB Statement

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.

Progress0 of 0 lessons

Statement Format

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
JOB + [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

Where JOB Fits in a Program

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 Options Compared

JOB INPUT modes
INPUT modeBehaviorHow activity ends
file-nameAutomatic sequential GET of that Library file each iterationAfter last automatic record (then FINISH if any)
(f1 KEY ... f2 KEY ...)Synchronized multi-file matching on KEY fieldsWhen synchronized input completes
NULLNo automatic input; you GET/READ yourselfMust STOP or TRANSFER
SQLAutomatic SQL rows; SELECT follows JOB immediatelyWhen SQL result set exhausted
(omit INPUT)Default prior SORT output or first Library fileSame 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.

Default INPUT When Omitted

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 Files and KEY

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 Procedures

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.

text
1
2
3
4
5
6
7
8
JOB 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 Procedures

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 Parameter

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 (z/OS)

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 Options

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.

JOB Body Patterns

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
FILE 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.

INPUT NULL Controlled Loop

text
1
2
3
4
5
6
7
JOB 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.

Testing JOB Activities

  1. Run JOB without INPUT after SORT; confirm default SORT output feeds the report.
  2. Add START DISPLAY; confirm it appears before any detail logic.
  3. STOP EXECUTE mid-JOB; confirm FINISH does not run.
  4. JOB INPUT NULL without STOP—cancel the runaway and fix the exit.
  5. Build two-file KEY match with known matched/unmatched keys; check IF MATCHED counts.

Common JOB Mistakes

  • JOB INPUT NULL without STOP or TRANSFER.
  • Referencing automatic file fields in START.
  • Expecting FINISH after STOP EXECUTE.
  • Synchronized KEY on unsorted inputs.
  • Forgetting NAME when EXECUTE must target the activity.
  • Assuming one JOB is the entire program when multiple activities exist.

Explain It Like I'm Five

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.

Exercises

  1. Write JOB INPUT with START and FINISH procedures.
  2. Explain default INPUT when SORT precedes JOB.
  3. Design synchronized INPUT with two KEY fields.
  4. Convert automatic INPUT to INPUT NULL plus GET/EOF/STOP.
  5. Document when FINISH is skipped.

Quiz

Test Your Knowledge

1. JOB defines and initiates:

  • A processing activity
  • Only JCL
  • Only PARM
  • Only macros

2. If you omit INPUT on JOB:

  • Default is prior SORT output or first Library file
  • No file ever reads
  • SQL always
  • CICS only

3. JOB INPUT NULL requires:

  • STOP or TRANSFER eventually or the activity loops
  • No FILE statements
  • Only PRINT
  • Only TITLE

4. START procedure runs:

  • Before the first automatic input record
  • After FINISH only
  • Only in CICS
  • During link-edit

5. Synchronized file matching uses:

  • INPUT (file KEY fields...) pairs
  • Only GET PRIOR
  • Only DISPLAY
  • Only MASK
Published
Read time18 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 JOB statementSources: Broadcom Easytrieve 11.6 Language Reference JOB Statement; JOB Activities getting startedApplies to: Easytrieve JOB activities