Every reusable block of Easytrieve logic begins with PROC. The keyword tells the compiler where a module starts, what label PERFORM must use, and where END-PROC must eventually close the block. Beginners arriving from COBOL often hunt for paragraphs or sections; in Easytrieve the pair is proc-name. PROC and END-PROC. Report writers use the same keyword with fixed names such as BEFORE-LINE and AFTER-BREAK. Online SCREEN activities use INITIATION and BEFORE-SCREEN. This page is the Procedures chapter deep dive on the opening statement itself: label rules, one-line versus two-line formats, placement inside each activity type, and how user PROCs differ from hooks the product calls for you. Master PROC placement before nesting, scope, and PERFORM patterns covered in sibling tutorials.
Think of PROC as the left bracket of a function in modern languages. Everything between PROC and END-PROC belongs to one module. The compiler builds a symbol table entry for the label so PERFORM can branch there. If you omit PROC or misspell the label, PERFORM references fail at compile time with undefined procedure messages. If you omit END-PROC, the compiler may absorb later statements into the wrong module or report an unterminated procedure—see the END-PROC tutorial for recovery patterns.
12345678VALIDATE-DEPT. PROC IF DEPT LT '01' OR DEPT GT '99' ERROR-FLAG = 'Y' ERROR-MSG = 'INVALID DEPARTMENT' ELSE ERROR-FLAG = 'N' END-IF END-PROC
VALIDATE-DEPT is the label PERFORM must reference. Statements inside the module can use IF, MOVE, GET, PRINT, nested PERFORM, and any executable statement allowed in that activity context. The module does not create a separate data area: fields defined in Library or working storage remain visible inside and after the PROC unless you deliberately isolate values in separate fields.
Broadcom documents proc-name. PROC on a single line as the common pattern. Some sites code the label alone on one line and PROC on the next; both forms declare the same module if delimiters follow release rules. Labels follow Easytrieve identifier rules: typically one to eight characters for user names unless your site extends limits in macro or library utilities. Special-name report and screen PROCs use reserved words documented in those chapters—do not invent alternate spellings expecting the report writer to find them.
| Pattern | Example | Notes |
|---|---|---|
| Label dot PROC | CALC-TAX. PROC | Most common user PROC form |
| Label then PROC | CALC-TAX PROC | Valid when delimiters satisfy grammar |
| Special report name | BEFORE-LINE. PROC | Invoked by report writer, not PERFORM |
| Job boundary name | START. PROC | Runs at JOB activity start when coded |
| Screen hook | BEFORE-SCREEN. PROC | Runs before each screen display cycle |
User PROCs are modules you name for your own PERFORM calls—CALC-TAX, FORMAT-ADDR, SKIP-RECORD. Special-name PROCs are contract hooks between your source and Broadcom runtime events. Coding BEFORE-LINE. PROC after a REPORT block tells the report writer to run that module before each detail line formats. PERFORM BEFORE-LINE is wrong for that hook; the product dispatches it when the event occurs. Confusing the two families is a frequent beginner mistake: special names are not optional nicknames, they are event entry points with documented restrictions on statements allowed inside them.
Source order matters in Easytrieve batch programs. Executable JOB statements—GET implied by JOB INPUT, IF, MOVE, PRINT, WRITE—appear first. User job PROCs such as START, FINISH, or your custom modules follow that executable section. REPORT subactivities come next, each followed immediately by its report PROCs. Mixing report PROCs among job PROCs or placing user PROCs before executable logic triggers compile errors about invalid statement sequence. The skeleton below shows a valid ordering beginners can copy into new programs.
12345678910111213141516171819202122232425JOB INPUT EMPFILE IF STATUS EQ 'T' PERFORM TERMINATED-RTN END-IF PRINT PAY-RPT START. PROC MOVE ZERO TO GRAND-TOTAL END-PROC TERMINATED-RTN. PROC TERM-COUNT = TERM-COUNT + 1 END-PROC REPORT PAY-RPT TITLE 'PAYROLL REGISTER' LINE EMP-ID EMP-NAME GROSS-PAY BEFORE-LINE. PROC ADD GROSS-PAY TO GRAND-TOTAL END-PROC TERMINATION. PROC * Grand total available for trailer logic if coded END-PROC
PROGRAM activities that replace or supplement batch JOB flows place user PROCs after executable PROGRAM statements using the same local-to-activity rule. SORT activities allow BEFORE prescreen PROCs named on the SORT statement; that procedure opens with the label from the BEFORE parameter followed by PROC and must SELECT records to include. SCREEN activities embed INITIATION, BEFORE-SCREEN, AFTER-SCREEN, and TERMINATION PROCs inside the SCREEN block rather than after it. Each activity is an island: a PROC defined at the end of JOB PAYROLL is invisible to PERFORM inside JOB BONUS—even in the same source member.
| Activity | User PROC location | Special PROC examples |
|---|---|---|
| JOB | After executable JOB, before REPORT | START, FINISH, REPORT-INPUT |
| REPORT (within JOB) | N/A—use report special names | BEFORE-LINE, AFTER-BREAK, ENDPAGE |
| SORT | BEFORE proc after SORT statement | Prescreen SELECT logic only |
| SCREEN | End of SCREEN executable section | INITIATION, BEFORE-SCREEN, AFTER-SCREEN |
| PROGRAM | After executable PROGRAM statements | Same family as JOB where documented |
PROC declares; PERFORM invokes. You code PROC once per module and may PERFORM many times from IF branches, implied JOB loops, or nested PROCs. There is no parameter list on PROC itself—input and output use shared fields set before PERFORM and read after END-PROC returns. The procedure parameters tutorial explains that pattern in detail. PERFORM transfers control to the first statement after PROC; END-PROC returns to the statement following the PERFORM that entered the module. Nested calls stack in order: inner END-PROC completes inner PERFORM before outer END-PROC runs.
Sites often suffix user PROCs with -RTN, -PROC, or -LOGIC for clarity in PERFORM lists. Keep names descriptive enough that maintenance programmers recognize purpose without opening the module— CALC-STATE-TAX beats PROC017. Avoid duplicating the same label in one activity; the compiler rejects duplicate labels. Different activities may reuse the same label text because scope is activity-local—a pattern sometimes used for parallel JOB steps that share copybook-like logic structure but not runtime linkage.
PROC is like writing a recipe card title at the top of a page. The title says this page is the chocolate-cake steps. When someone says make chocolate cake, they flip to that page—that is PERFORM. The recipe ends when you write the end on the card—that is END-PROC. Some recipe titles are ones you invent. Others are names the kitchen teacher already chose, like before-dinner-setup, and the teacher opens that card automatically at the right moment without you calling it.
1. A user procedure module opens with:
2. BEFORE-LINE. PROC is invoked by:
3. Job user PROCs belong:
4. The period after proc-name in proc-name. PROC typically means:
5. PROC differs from JCL PROC because: