Easytrieve GOTO Statement

GOTO modifies the natural top-to-bottom flow of Easytrieve statements. You can branch to a named label inside the same activity or procedure, to the top of the current JOB activity (GOTO JOB), or to the top of the current SCREEN activity (GOTO SCREEN). The synonym GO TO is accepted. GOTO JOB is the everyday batch pattern for skipping a record after validation fails—control returns to the JOB loop for the next automatic input record without re-executing START. GOTO SCREEN refreshes online flow including BEFORE-SCREEN but not INITIATION, and it is illegal inside BEFORE-SCREEN. Labels follow naming rules similar to other Easytrieve names: up to 128 characters, not all numeric, starting with letter, digit, or national character. Structured programming favors IF, DO, and PERFORM, but GOTO JOB remains idiomatic and documented for record bypass. This page covers syntax, label placement, JOB and SCREEN targets, START/FINISH interactions, and safer patterns so beginners do not invent spaghetti branches across activities.

Progress0 of 0 lessons

Statement Format

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{GOTO | GO TO} {label | JOB | SCREEN} * Skip bad record in batch: IF PAY-GROSS NOT NUMERIC DISPLAY EMP# ' DAMAGED' GOTO JOB END-IF * Branch to a label inside a PROC: IF CURR-MM NE HIRE-MM GOTO QUIT-SERV-CALC END-IF ... QUIT-SERV-CALC * next statements...

Three Targets Compared

GOTO destinations
TargetEffectImportant notes
labelJump to first statement after that label; then continue top-to-bottomLabel must be in same activity or procedure
JOBImmediate branch to top of current JOB activityDoes not run START; in START/FINISH it terminates that procedure
SCREENBranch to top of current SCREEN including BEFORE-SCREENSkips INITIATION; invalid in BEFORE-SCREEN; in TERMINATION ends screen

Label Rules

A statement label is itself a complete statement. You place it before executable statements such as assignment, CASE, GET, IF, PERFORM, PRINT, READ, STOP, WRITE, and many others listed in the Broadcom GOTO article. Labels may be up to 128 alphanumeric characters, may contain characters other than delimiters, may begin with A–Z, 0–9, or national characters (#, @, $), and must not be all numeric. After GOTO label, processing continues from the labeled point downward—there is no automatic return like PERFORM provides.

GOTO JOB in Detail

GOTO JOB is the standard way to abandon remaining logic for the current automatic input record and fetch the next. It does not include execution of the START procedure. Typical uses: reject non-numeric amounts, skip inactive departments, bypass records outside a date range after DISPLAY of a warning. Inside a START procedure, GOTO JOB terminates START (you are not requesting another full START cycle). Inside FINISH, GOTO JOB terminates FINISH early—usually undesirable if FINISH prints totals, so avoid casual GOTO JOB in FINISH.

text
1
2
3
4
5
6
7
JOB INPUT PERSNL NAME MYPROG IF DEPT LT 900 GOTO JOB END-IF PRINT RPT REPORT RPT LINE EMP# NAME-LAST DEPT

Records with DEPT less than 900 never reach PRINT. The JOB activity continues until automatic input is exhausted. This is clearer than deeply nested ELSE trees when many independent skip reasons exist—each reason can GOTO JOB after its own message.

GOTO SCREEN in Detail

GOTO SCREEN branches to the top of the current SCREEN activity and runs BEFORE-SCREEN again, but does not run INITIATION. Use it from AFTER-SCREEN or other allowed points when the user must see a rebuilt screen after edits. Restrictions matter:

  • Do not code GOTO SCREEN in BEFORE-SCREEN (or procedures performed only from it).
  • In INITIATION, GOTO SCREEN terminates INITIATION.
  • In TERMINATION, GOTO SCREEN terminates the screen activity.

Confusing GOTO SCREEN with REFRESH or RESHOW causes subtle online bugs—those verbs have their own rules and are also restricted in BEFORE-SCREEN. See BEFORE-SCREEN and AFTER-SCREEN tutorials.

GOTO Label Versus PERFORM

PERFORM name runs a PROC and returns. GOTO label transfers without return. Application Guide samples often GOTO a local label to exit early from a calculation PROC (for example QUIT-SERV-CALC) then fall into END-PROC. That pattern is acceptable when the label sits in the same PROC. Jumping into the middle of another PROC or across JOB activities is not supported—the label must stay in the same activity or procedure. Prefer PERFORM for reusable logic; prefer GOTO JOB for record bypass; use local labels sparingly for early exits inside one PROC.

Structured Programming Guidance

Broadcom structured-programming guidance emphasizes IF/ELSE/ELSE-IF, DO loops, and consistent indentation. GOTO is not banned, but nesting many label jumps makes maintenance hard. A practical beginner policy:

  1. Use GOTO JOB freely for skip-to-next-record.
  2. Use PERFORM for shared calculations.
  3. Limit GOTO label to short early exits inside one PROC.
  4. Avoid building a web of labels that mimic assembler spaghetti.

Interaction With IF

text
1
2
3
4
5
6
7
8
9
IF PAY-GROSS NOT NUMERIC DISPLAY EMP# ' PERSONNEL RECORD IS DAMAGED' GO TO JOB END-IF IF PAY-GROSS > 500.00 XMAS-BONUS = PAY-GROSS * 1.03 ELSE XMAS-BONUS = PAY-GROSS * 1.05 END-IF

The first IF uses GO TO JOB so damaged records never compute bonuses. Control never returns to the statements after GOTO—exactly what you want for reject paths.

Testing GOTO Behavior

  1. Count PRINT lines with and without GOTO JOB skip logic on known test data.
  2. Place GOTO JOB in START; confirm START ends and automatic input begins.
  3. Attempt GOTO SCREEN in BEFORE-SCREEN; document the diagnostic.
  4. GOTO a label past END-PROC accidentally—confirm compile failure.
  5. Replace a local GOTO early exit with nested IF and compare readability.

Common GOTO Mistakes

  • Expecting GOTO JOB to re-run START initialization.
  • GOTO SCREEN inside BEFORE-SCREEN.
  • Label in a different activity than the GOTO.
  • All-numeric label names.
  • Using GOTO when PERFORM should return.
  • GOTO JOB in FINISH before totals DISPLAY.

Explain It Like I'm Five

Easytrieve normally reads your instructions from top to bottom like a story. GOTO is a sticky note that says “jump to this page.” GOTO JOB means “skip the rest of this card and take the next card from the deck.” GOTO SCREEN means “draw the online form again from the start of the form loop.” Labels are page bookmarks inside the same chapter—you cannot jump to a bookmark in a different book.

Exercises

  1. Write IF validation that DISPLAY then GOTO JOB.
  2. Explain START behavior when GOTO JOB executes inside START.
  3. List three differences between GOTO JOB and GOTO SCREEN.
  4. Create a PROC with a local early-exit label.
  5. Refactor one GOTO label into structured IF without changing results.

Quiz

Test Your Knowledge

1. GOTO JOB branches to:

  • Top of current JOB activity without re-running START
  • JCL JOB card
  • Only REPORT
  • Link-edit

2. A GOTO label must be:

  • In the same activity or procedure
  • In another program only
  • Only in PARM
  • Only in JCL

3. GOTO SCREEN cannot be coded in:

  • BEFORE-SCREEN procedure
  • AFTER-SCREEN
  • Any PROC
  • FINISH only

4. GO TO is:

  • An allowed synonym of GOTO
  • Invalid always
  • Only for SQL
  • Only for SORT

5. GOTO JOB inside START procedure:

  • Terminates the START procedure
  • Restarts START forever
  • Opens CICS
  • Ignores JOB
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 GOTO statementSources: Broadcom Easytrieve 11.6 Language Reference GOTO Statement; Application Guide samplesApplies to: Easytrieve GOTO flow control