The PROC statement opens a procedure module—a reusable block of Easytrieve logic bounded by END-PROC. Instead of duplicating tax calculation in twelve IF branches, you code CALC-TAX. PROC once and PERFORM CALC-TAX wherever needed. Broadcom supports user PROCs at the end of JOB, PROGRAM, SCREEN, and SORT activities, plus special-name report PROCs such as BEFORE-LINE and FINISH that the report writer invokes automatically. The PROC keyword is both delimiter and documentation: maintainers see where modular logic begins and ends. Beginners confuse PROC with COBOL paragraphs or JCL procedures; in Easytrieve PROC is in-program structure only. This page teaches statement format, placement rules, PERFORM pairing, nesting without recursion, report PROC names, and mistakes that cause compile errors or wrong return points after END-PROC.
123456proc-name. PROC * executable statements END-PROC * Invocation: PERFORM proc-name
Proc-name is a label identifying the module. Broadcom allows proc-name. PROC on one line or the label on one line and PROC on the next with proper delimiters. Every PROC must have matching END-PROC. PERFORM proc-name branches to the first statement after PROC; END-PROC returns to the statement following PERFORM.
| Type | Naming | How it runs |
|---|---|---|
| User PROC | Your label (CALC-TAX) | PERFORM proc-name |
| Job PROC | START, FINISH | Automatically at JOB boundaries |
| Report PROC | BEFORE-LINE, AFTER-BREAK | Report writer events |
| Screen PROC | BEFORE-SCREEN, TERMINATION | SCREEN activity hooks |
User PROCs are generic modules you design. Special-name PROCs use reserved labels documented in the report or screen chapters—coding BEFORE-LINE. PROC after a REPORT subactivity hooks detail line formatting; PERFORM is wrong for those hooks because the product calls them.
Executable JOB statements—IF, MOVE, PRINT, GET—come first. Job PROCs such as START and FINISH follow executable logic. REPORT subactivities come after job PROCs. Report PROCs immediately follow the REPORT block they serve. Violating order produces compile errors that mention unexpected REPORT or PROC placement. A minimal skeleton:
1234567891011121314151617JOB INPUT PAYROLL IF DEPT EQ '99' PERFORM SKIP-RECORD END-IF PRINT DETAIL-RPT START. PROC MOVE ZERO TO TOTAL-AMT END-PROC REPORT DETAIL-RPT TITLE 'PAYROLL LISTING' LINE EMP-NO EMP-NAME SALARY BEFORE-LINE. PROC ADD SALARY TO TOTAL-AMT END-PROC
PERFORM is the only way to invoke user PROCs. It is not a parameter pass like CALL USING—PROC shares Library fields and working storage with the caller. Changes to fields inside PROC remain visible after END-PROC unless you deliberately MOVE to local copies. Nested PERFORM is allowed: OUTER-PROC may PERFORM INNER-PROC. Recursion—OUTER performing INNER performing OUTER—is forbidden and yields unpredictable results or compile rejection.
END-PROC must appear for every PROC. Omitting END-PROC leaves the compiler assuming later statements belong to the module, breaking REPORT placement and IF nesting. END-PROC is not END-IF; do not interchange them. Multiple PROCs in one activity each need their own END-PROC pair. EXIT inside PROC ends procedure flow early without executing remaining PROC statements— still requires eventual END-PROC at module level for structure.
PROGRAM activities place user PROCs after top-down executable statements. SCREEN activities place screen PROCs—INITIATION, BEFORE-SCREEN, AFTER-SCREEN, TERMINATION—in documented positions within the SCREEN block. BEFORE-SCREEN forbids GOTO SCREEN, REFRESH, and RESHOW; those restrictions apply to statements inside that PROC, not to PROC syntax itself.
| Aspect | PROC / PERFORM | CALL |
|---|---|---|
| Scope | Same Easytrieve program | External load module |
| Parameters | Shared fields | USING list |
| Return | END-PROC to PERFORM+1 | RETURN or RETURNS field |
| Languages | Easytrieve only | COBOL, Assembler, C, etc. |
PROC is a recipe card in a box. END-PROC is the bottom of the card. PERFORM means "go read that recipe now, then come back here when the card ends." You can put a recipe inside another recipe, but you cannot have recipe A call recipe B call recipe A again—that goes in circles. Special recipe names like BEFORE-LINE are ones the report machine reads automatically when it prints each line—you do not call those yourself.
1. A user PROC begins with:
2. PERFORM transfers control to a PROC and returns after:
3. Procedures are local to:
4. Recursion between PROCs is:
5. BEFORE-LINE. PROC is a: