Easytrieve Activity Section

If the Library section tells Easytrieve what your data looks like, the Activity section tells it what to do. This is where files are read, conditions tested, totals accumulated, extracts written, sorts invoked, and reports triggered. Broadcom requires at least one activity in every program. Batch beginners spend most of their time in JOB activities, but PROGRAM, SORT, and SCREEN activities complete the picture for driver logic, ordered files, and online transactions. Understanding activity types and statement order prevents compile errors and makes large programs easier to navigate.

Progress0 of 0 lessons

Activity Section Basics

Activity sections contain procedural statements that run during execution and declarative statements that describe structures like reports. The compiler processes activities in program order unless EXECUTE or other control statements redirect flow. Each activity can have a label so other parts of the program or EXECUTE statements can target it by name.

JOB Activities — Batch Processing Core

JOB activities implement the classic read-process-write loop. JOB INPUT names the primary file driving the loop. For each record read, statements between JOB INPUT and the end of the job executable section run. IF blocks filter records. Assignment statements compute values. WRITE or PUT statements send data to output files. PRINT connects detail lines to REPORT definitions declared later in the same JOB activity.

text
1
2
3
4
5
6
7
JOB INPUT PERSNL NAME PAYJOB IF DEPT EQ 'ACC' ADD GROSS TO WS-TOTAL PRINT PAY-RPT END-IF WHEN EOF DISPLAY 'RECORDS PROCESSED' COUNT

PAYJOB labels this activity. PERSNL must be defined in Library and allocated in JCL. The IF tests department code ACC. Matching records add GROSS to working storage WS-TOTAL and PRINT detail to report PAY-RPT. WHEN EOF runs once at end of file—useful for trailer displays or final totals if not handled entirely in REPORT control breaks.

Conditional Logic and Control Flow

IF, ELSE, END-IF, and related constructs filter which records contribute to output or calculations. Nesting is allowed within documented limits, but deeply nested logic hurts readability. Many shops move repeated tests into job PROCs. Comparisons use fields defined in Library; comparing undefined names fails at compile time. Mixing numeric and character comparisons without attention to type causes subtle runtime errors—another reason Library accuracy matters before Activity coding begins.

PRINT and Report Connection

PRINT does not format columns by itself in the way REPORT LINE does. It selects data for a named report defined in a REPORT subactivity at the end of the JOB. Think of PRINT as saying this record should appear on report PAY-RPT; the REPORT section defines how columns, titles, and totals appear. Removing PRINT while leaving REPORT in place yields empty reports even when IF logic seems correct.

PROGRAM Activities — Coordinators

PROGRAM activities execute top-down like a simple script. They suit initialization, parameter-driven branching, and calling other activities through EXECUTE. For example, a PROGRAM might read a control card, then EXECUTE either a detail JOB or a summary JOB depending on a flag. PROGRAM is not a replacement for JOB when you need record-by-record file processing—use JOB for that loop.

text
1
2
3
4
5
6
PROGRAM NAME DRIVER IF RUN-TYPE EQ 'DETAIL' EXECUTE PAYDET ELSE EXECUTE PAYSUM END-IF

DRIVER runs once per program invocation unless called again. RUN-TYPE might come from a control file or DEFINE field populated earlier. EXECUTE transfers control to labeled JOB activities PAYDET or PAYSUM. This pattern keeps one source member and one load module while supporting multiple batch modes.

SORT Activities

SORT activities create ordered files without hand-coding sort logic in JOB. They specify input, output, and keys according to Easytrieve sort syntax documented in the language reference. SORT is appropriate when downstream JOB activities require sequenced input—by employee, account, or date—before control-break reporting. A PROGRAM or SCREEN activity can EXECUTE SORT when sorting is conditional.

SCREEN Activities — Online Processing

SCREEN activities handle terminal-oriented work: display panels, accept operator input, read and update files interactively. They can EXECUTE JOB or SORT activities for batch side effects such as printing a report after online approval. SCREEN uses screen procedures at the end of the activity, analogous to job PROCs. Batch-only developers can defer SCREEN depth until online topics, but should recognize SCREEN as a peer activity type—not a special syntax inside JOB.

Procedures in Activities

PROCs modularize repeated logic. Job PROCs sit after executable JOB statements. Screen PROCs follow SCREEN logic. CALL or PERFORM-style invocation depends on documented Easytrieve syntax for your release. PROCs improve maintenance when the same validation or calculation appears in multiple IF branches. They do not replace REPORT subactivities—reports remain declarative blocks after PROCs.

Procedural vs Declarative in Activity

Statement categories within Activity sections
CategoryExamplesWhen it runs
ProceduralJOB INPUT, IF, ADD, MOVE, WRITE, PRINTDuring record processing or program flow
DeclarativeREPORT, TITLE, LINE, CONTROLDefined at compile time; used when report events fire
Procedural modulesJob PROCs, screen PROCsWhen invoked from procedural statements

Activity Labels and Multiple Jobs

Labels such as NAME on JOB or PROGRAM identify activities for EXECUTE and for compiler cross-references. Large programs may define several JOB activities sharing one Library section—payroll detail, payroll summary, error extract—each with its own INPUT file and REPORT set. Labels must be unique and meaningful for operations documentation.

Debugging Activity Logic

DISPLAY statements trace values during test runs. Combine DISPLAY with controlled test files rather than production volumes. When abends occur, PARM DEBUG STATE and FLOW help map runtime failure back to Activity statement numbers. Remove verbose DISPLAY before production because spool volume and runtime cost grow quickly on large files.

Common Activity Mistakes

  • Referencing fields not defined in Library.
  • Expecting REPORT definitions inside IF blocks instead of after job PROCs.
  • Using JOB INPUT with a file name that has no matching DD at execute time.
  • Forgetting PRINT so reports never receive detail lines.
  • Calling EXECUTE targets that are not labeled JOB or SORT activities.

Explain It Like I'm Five

The Activity section is the part of the script where actors actually walk on stage. JOB is the main scene where each paper record from a stack gets read and decided upon. PROGRAM is the stage manager who chooses which scene plays next. SORT is organizing the stack before the scene. SCREEN is talking to someone in the audience and writing down their answers. Without Activity, the play never starts—only character lists and rule sheets exist.

Exercises

  1. Write a JOB activity that reads PERSNL and prints only records with DEPT equal to SAL.
  2. Add a PROGRAM activity that EXECUTEs two different JOB labels based on a flag field.
  3. Explain why PRINT is needed for detail lines to appear on a REPORT.
  4. List where job PROCs and REPORT subactivities belong in a JOB activity.
  5. Describe one DISPLAY-based test technique and one production caution about it.

Quiz

Test Your Knowledge

1. JOB INPUT names:

  • The file the job activity reads
  • The JCL job name
  • The compiler option table
  • The spool class

2. PRINT in a JOB activity typically:

  • Selects detail lines for a report
  • Allocates DD statements
  • Compiles macros
  • Links object modules

3. EXECUTE in a PROGRAM activity:

  • Runs another JOB, SORT, or SCREEN activity conditionally
  • Ends the JCL job
  • Deletes a file
  • Only comments source

4. SORT activities are used to:

  • Create sequenced or ordered output files
  • Define screen colors
  • Replace FILE statements
  • Skip Library section

5. Job PROCs appear:

  • After executable JOB statements at the end of the JOB activity
  • Before PARM
  • Inside REPORT TITLE lines
  • Only in JCL
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 Activity section types and JOB processing patternsSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, Program Sections, Activity Section documentationApplies to: Easytrieve JOB, PROGRAM, SORT, and SCREEN activity coding