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.
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 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.
1234567JOB 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.
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 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 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.
123456PROGRAM 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 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 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.
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.
| Category | Examples | When it runs |
|---|---|---|
| Procedural | JOB INPUT, IF, ADD, MOVE, WRITE, PRINT | During record processing or program flow |
| Declarative | REPORT, TITLE, LINE, CONTROL | Defined at compile time; used when report events fire |
| Procedural modules | Job PROCs, screen PROCs | When invoked from procedural statements |
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.
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.
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.
1. JOB INPUT names:
2. PRINT in a JOB activity typically:
3. EXECUTE in a PROGRAM activity:
4. SORT activities are used to:
5. Job PROCs appear: