Easytrieve LABEL — Statement Labels and Branch Targets

Beginners searching for a LABEL statement in the Broadcom Language Reference will not find a standalone keyword. Easytrieve labels are names you attach to statements and activities so GOTO, PERFORM, and human readers can find logic blocks. A label is the name followed by a period, then the next statement executes as the entry point. This tutorial uses LABEL as the concept name because it appears in statement indexes and parallels COBOL paragraph names, but the mechanics are statement labels and activity labels documented in the Statement Overview chapter. Understanding labels is essential before mastering GOTO, PROC structure, and report event procedures such as BEFORE-LINE. This page teaches naming rules, scope within JOB and PROC, special activity labels, period terminators, comparison with PERFORM modules, and maintainable alternatives to spaghetti branching.

Progress0 of 0 lessons

What a Statement Label Looks Like

A statement label occupies the statement area before executable code. Broadcom terminates statements with a period followed by a space when another statement follows on the same line. The label itself ends with a period; the statement after the label is where GOTO lands. Labels are not indented like COBOL Area A paragraphs—Easytrieve free form allows labels starting in the statement area per site listing options.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
JOB INPUT PERSNL NAME DIV-LIST IF DIV = 'A' GOTO JOB END-IF IF DIV = 'B' GOTO CHECK-REG-ROUTINE END-IF PRINT DETAIL-RPT CHECK-REG-ROUTINE. IF REGION NE 'EAST' GOTO JOB END-IF PRINT DETAIL-RPT

CHECK-REG-ROUTINE is a statement label. GOTO CHECK-REG-ROUTINE transfers to the IF immediately below the label. GOTO JOB at the top skips the current employee record entirely by branching to the next JOB INPUT cycle. DIV-LIST on the JOB line is an activity label naming that job—not the same as a statement label inside the job, though both use the period convention in different contexts.

Label Naming Rules

Broadcom label rules (statement and activity labels)
RuleDetail
Maximum lengthUp to 128 characters
Valid start characterA–Z, 0–9, or national # @ $
Invalid labelCannot consist entirely of numeric characters
DelimitersCommas, quotes, and other delimiters cannot appear inside the label name
DBCSDouble-byte characters permitted where site supports them

Names like 101-ROUTINE are valid because they are not all numeric. A label named 12345 alone is invalid. Use descriptive names—VALIDATE-ZIP, SKIP-RECORD, AFTER-TAX-CALC—so maintenance programmers recognize purpose without reading every GOTO source.

Activity Labels Versus Statement Labels

PROGRAM NAME MYPROG labels the program. JOB INPUT PERSNL NAME PAYROLL labels a job activity. REPORT PAY-RPT names a report subactivity. SCREEN INQUIRY names a screen activity. These activity labels appear on the declaring statement and are referenced by PRINT PAY-RPT, PERFORM procedures, or product-defined hooks. Statement labels live inside the activity body and serve GOTO targets only within that activity or nested PROC unless you explicitly branch across boundaries—which GOTO does not do for arbitrary labels in other activities.

Label types in a typical program
Label typeExampleReferenced by
ProgramPROGRAM NAME LEDGERCALL, linker, listings
JOB activityJOB INPUT FILE-A NAME BATCH1Multiple JOB blocks, documentation
PROCCALC-TAX. PROCPERFORM CALC-TAX
StatementERROR-HANDLER.GOTO ERROR-HANDLER
REPORTREPORT SUMMARY-RPTPRINT SUMMARY-RPT

GOTO and Label Scope

GOTO label requires the label in the same activity or PROC as the GOTO. You cannot GOTO a label in a different JOB from another JOB. PROC labels are local to the PROC when branching inside it; PERFORM enters the PROC at the first statement after the PROC label without using GOTO. GOTO JOB and GOTO SCREEN are special forms branching to activity tops—not arbitrary labels. GOTO SCREEN runs BEFORE-SCREEN again; GOTO JOB skips to the next input record cycle.

Labels and PROC Names

A PROC begins with name PROC and ends with END-PROC. The PROC name acts as a label for PERFORM invocation. Code inside the PROC may contain additional statement labels for internal GOTO. BEGINNERS sometimes duplicate a PROC name as an internal label—avoid confusion by keeping PROC entry logic immediately after the PROC line without a redundant label unless GOTO must target mid-PROC logic.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
TAX-CALC. PROC IF STATE = 'TX' GOTO TEXAS-RATE END-IF RATE = FED-PCT GOTO APPLY-RATE TEXAS-RATE. RATE = TX-PCT APPLY-RATE. TAX = GROSS * RATE END-PROC

Period Terminators and Multiple Statements

Easytrieve allows multiple statements on one line when each ends with period and space. A label line often contains only the label and period. Do not omit the period after a label; without it the compiler may treat the label as part of the next statement keyword and fail. Continuation lines use hyphen or plus at end of statement area per syntax rules—labels themselves do not continue across lines.

Structured Alternatives to GOTO Labels

Broadcom structured programming guidance recommends IF, ELSE, DO WHILE, and PERFORM instead of deep GOTO webs. Labels remain appropriate for GOTO JOB record skips, centralized error handlers invoked from many IF branches, and legacy patterns you must preserve during migration. New code should default to PERFORM PROC for reusable modules and nested IF for two-way decisions.

  • GOTO JOB — skip record when filter rejects early.
  • PERFORM VALIDATE-ZIP — reusable validation with return.
  • IF/ELSE — branch without naming a paragraph for simple cases.
  • CASE — multi-way value branch when your release supports it.

Labels in Report and Screen Activities

Report PROCs and screen procedures use special-name labels such as BEFORE-LINE. PROC and INITIATION are not arbitrary user labels—they are product-reserved procedure names. User statement labels inside REPORT PROCs follow the same GOTO scope rules within that PROC. Mixing report event procedure names with custom labels causes compile errors if you misspell a reserved hook name.

Common Label Mistakes

  • All-numeric label names rejected at compile.
  • GOTO to label in different JOB activity.
  • Missing period after label name.
  • Duplicate label names in same scope.
  • Expecting GOTO to return like PERFORM.
  • Using LABEL as a keyword instead of name-plus-period.

Explain It Like I'm Five

A label is a sticky note on a line of your program that says jump here. When GOTO says go to CHECK-REG-ROUTINE, the computer finds that sticky note and runs the next instruction under it. Activity names like JOB PAYROLL are bigger sticky notes on whole chapters. You cannot jump to a sticky note in someone else's book chapter unless the rules say you stay in the same chapter. PERFORM is like calling a helper who comes back when done; GOTO is like jumping without automatic return.

Exercises

  1. Write JOB logic with GOTO JOB for one skip condition and a named label for another branch.
  2. List five valid and two invalid label names with reasons.
  3. Rewrite a two-branch GOTO pattern using IF/ELSE only.
  4. Explain scope difference between DIV-LIST job label and CHECK-REG statement label.
  5. Add internal labels inside a PROC reached only by GOTO within that PROC.

Quiz

Test Your Knowledge

1. A statement label in Easytrieve is written as:

  • label-name followed by a period
  • LABEL keyword then name
  • JCL //LABEL card
  • END-LABEL terminator

2. GOTO CHECK-REG transfers control to:

  • First statement after CHECK-REG label in same activity or PROC
  • Another JCL step
  • Library section
  • Compile listing

3. A valid label name may:

  • Start with A–Z, 0–9, or national # @ $
  • Be all numeric digits only
  • Contain commas
  • Exceed 256 characters

4. GOTO JOB branches to:

  • Top of current JOB activity
  • Named external program
  • REPORT TITLE block
  • Environment PARM

5. Structured flow guidance favors:

  • IF/ELSE and PERFORM over deep GOTO chains
  • GOTO for every branch
  • No labels ever
  • Labels only in JCL
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 Statement Overview and GOTO label rulesSources: Broadcom Easytrieve 11.6 Statement Overview, GOTO Statement, JOB ActivitiesApplies to: Easytrieve statement labels and branch targets