Easytrieve STOP Statement

Every Easytrieve activity must end somehow. JOB activities with automatic INPUT stop when the file reaches end-of-file—implied flow runs FINISH, wraps reports, and advances to the next activity. But real programs exit early when validation fails, when a control file is empty, when an operator presses Exit, or when a NULL-input JOB finishes its manual GET loop. STOP is the primary verb for premature activity termination. STOP alone ends the current activity in an orderly way: complete spooled reports where applicable, run FINISH on JOB, commit recoverable work when COMMIT ACTIVITY applies, then let subsequent activities run. STOP EXECUTE is the emergency brake—it aborts all Easytrieve processing immediately, skips FINISH, rolls back recoverable resources, and leaves no further JOB or SORT to execute. SORT BEFORE procedures use STOP to end prescreening and launch the sort pass. SCREEN activities compile only when EXIT, STOP, or TRANSFER appears somewhere. This page teaches STOP syntax, context-specific behavior in JOB SORT SCREEN and procedures, interaction with SELECT and FINISH, COMMIT and ROLLBACK pairing, and 11.6 syntax differences from legacy releases.

Progress0 of 0 lessons

Statement Format

text
1
STOP [EXECUTE]

Two forms: STOP ends the current activity; STOP EXECUTE ends the entire program run. On Easytrieve 11.6 use STOP EXECUTE—not legacy STOP (EXECUTE) parentheses form from 6.4, which errors on modern compilers. No other operands appear on STOP.

STOP Versus STOP EXECUTE

Termination comparison
FormScopeFINISH procedureRecoverable work
STOPCurrent activity onlyRuns on JOB when codedCOMMIT when COMMIT ACTIVITY specified
STOP EXECUTEAll activities immediatelySkippedROLLBACK
EOF (automatic)Current JOB ends naturallyRuns when codedPer COMMIT options
EXIT (SCREEN)Normal SCREEN endN/A for JOB FINISHPer SCREEN COMMIT

STOP in JOB Activities

Automatic INPUT JOB activities terminate at EOF without explicit STOP. Use STOP when business logic must quit before EOF—fatal edit on first record, empty control file after START, operator threshold exceeded. STOP completes outstanding reports for that JOB and executes FINISH when FINISH procedure is coded. GOTO JOB is not STOP—it skips to next record iteration. STOP leaves the read loop entirely.

JOB INPUT NULL has no automatic EOF. Every NULL job must reach STOP or TRANSFER or it loops forever consuming CPU. Pattern: DO WHILE manual GET, process, IF EOF STOP. Test NULL jobs carefully in development—missing STOP is a classic runaway job ticket.

text
1
2
3
4
5
6
JOB INPUT NULL NAME MANUAL-READ GET SECFILE IF EOF SECFILE STOP END-IF * process SECFILE record

STOP EXECUTE in FINISH

Broadcom example: FINISH procedure tests RECORD-COUNT = 0, DISPLAYs error messages, then STOP EXECUTE when input file was unavailable—preventing a useless SORT and second JOB from running in the same program. STOP EXECUTE in FINISH aborts before subsequent activities execute—critical in multi-activity sources where later JOB assumes prior activity produced data.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
JOB INPUT INVENT NAME MYPROG1 FINISH FINISH-PROC PRINT MYREPORT FINISH-PROC. PROC IF RECORD-COUNT = 0 DISPLAY 'INPUT FILE NOT AVAILABLE' DISPLAY 'HALTING EXECUTION...' STOP EXECUTE END-IF END-PROC SORT INVENT TO SORTWRK USING (LOCATION-STATE, LOCATION-CITY) JOB INPUT SORTWRK NAME MYPROG2 PRINT MYREPORT

STOP in SORT BEFORE Procedures

STOP in a SORT prescreen procedure terminates record selection and invokes the sort program. Use it to cap records sorted—first fifty only example—or when input order signals early end. If you SELECT a record and later STOP in the same procedure invocation, that record is not selected. Plan SELECT/STOP ordering when mixing inclusion flags with early prescreen exit.

STOP in START or FINISH Procedures

STOP coded inside START or FINISH terminates that procedure—not always the entire JOB unless STOP propagates per context. STOP EXECUTE inside FINISH aborts all execution. Plain STOP inside START ends START procedure early; JOB may continue to input processing depending on surrounding logic. Read Broadcom JOB GOTO rules alongside STOP when mixing control verbs in lifecycle procedures.

STOP on SCREEN Activities

SCREEN activities require EXIT, STOP, or TRANSFER so compile succeeds. EXIT is normal end; STOP ends the SCREEN activity and may chain to batch activities depending on PROGRAM flow. KEY F3 NAME 'Exit' EXIT is idiomatic online. STOP on SCREEN from PF key is valid when designers want shared semantics with batch STOP in hybrid programs.

STOP in PROGRAM Activity

Explicit PROGRAM activities end when statements complete, or when STOP, STOP EXECUTE, or TRANSFER runs. PROGRAM must EXECUTE other activities—STOP after last EXECUTE ends driver. STOP EXECUTE from PROGRAM prevents further EXECUTE of downstream SORT/JOB even if source order lists more activities.

COMMIT Interaction

When COMMIT ACTIVITY is specified on the activity statement, STOP causes commit of recoverable work. STOP EXECUTE causes rollback. Online SCREEN COMMIT TERMINAL settings interact with pseudo- conversational CICS—coordinate STOP with operational transaction design so partial updates are not left uncommitted or over-committed relative to shop standards.

STOP Versus Other Endings

Activities do not use END-JOB keywords—next JOB or SORT activity implicitly ends the prior one at normal batch flow boundaries. STOP is explicit early exit within an activity. TRANSFER passes control to another context per release rules—do not interchange with STOP without reading TRANSFER documentation. END-IF END-DO END-PROC close blocks—they do not end activities.

Common STOP Mistakes

  • JOB INPUT NULL without STOP or TRANSFER—infinite loop.
  • Expecting FINISH after STOP EXECUTE—it does not run.
  • Legacy STOP (EXECUTE) syntax on 11.6 compiler.
  • SELECT then STOP in sort proc wondering why record vanished.
  • Using STOP when GOTO JOB meant skip to next record only.
  • SCREEN missing EXIT/STOP/TRANSFER—compile error.

Testing STOP Behavior

  1. Trigger STOP mid-JOB—confirm FINISH DISPLAY appears with plain STOP.
  2. Trigger STOP EXECUTE in FINISH—confirm later SORT/JOB never starts.
  3. NULL job EOF path—confirm STOP and clean job end code.
  4. SORT BEFORE cap—verify output record count with STOP threshold.
  5. SCREEN Exit key—confirm activity ends without batch fall-through surprises.

Explain It Like I'm Five

STOP is telling the teacher we are done with this worksheet now—put away your pencil, hand in what you finished (that is FINISH and reports), and move to the next subject if there is one. STOP EXECUTE is pulling the fire alarm for the whole school day—everyone goes home immediately, nothing else on the schedule runs, and undone work gets erased (rollback). You need STOP on manual worksheets (NULL jobs) because the teacher will not say time is up unless you raise your hand.

Exercises

  1. Write JOB INPUT NULL loop with EOF STOP.
  2. Explain one sentence each: STOP vs STOP EXECUTE vs EXIT on SCREEN.
  3. Sketch FINISH-PROC with RECORD-COUNT check and STOP EXECUTE.
  4. Describe SELECT then STOP effect in SORT BEFORE proc.
  5. State when FINISH runs and when it does not relative to STOP forms.

Quiz

Test Your Knowledge

1. STOP without EXECUTE:

  • Ends current activity; later activities may still run
  • Ends entire program always
  • Only closes SYSPRINT
  • Compiles Library

2. STOP EXECUTE:

  • Immediately terminates all Easytrieve execution
  • Runs FINISH on every JOB
  • Only ends SORT
  • Requires EXIT on SCREEN

3. JOB INPUT NULL requires STOP because:

  • No automatic EOF ends the activity
  • FILES never open
  • REPORT invalid
  • SQL only

4. STOP in JOB body normally:

  • Completes reports and runs FINISH if coded
  • Skips FINISH when STOP EXECUTE
  • Opens files
  • Runs START again

5. SELECT then STOP in sort procedure:

  • Record is not selected
  • Record sorts twice
  • FINISH always runs
  • SCREEN displays

Related Pages

Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 STOP StatementSources: Broadcom Easytrieve 11.6 STOP Statement, JOB and SORT activity termination examplesApplies to: Easytrieve STOP and STOP EXECUTE