BEFORE-LINE is a special-name report procedure invoked immediately before the report writer prints each detail line defined by LINE statements. JOB logic and PRINT select which records appear; LINE declares column layout; BEFORE-LINE is your final edit pass on the values about to print. Change amounts for display masks, blank sensitive fields on certain rows, stamp run date on the first detail after a page overflow, or set annotation literals. When REPORT defines multiple LINE rows as a group, BEFORE-LINE runs before each individual line in that group—system field LINE-NUMBER tells you which row in the group is active. Format is BEFORE-LINE. PROC with END-PROC terminator, placed after the REPORT block. Do not PERFORM it. Legacy shops may still say BEFORE-DETAIL from IBM manuals; Broadcom 11.6 standardizes BEFORE-LINE. This page covers syntax, timing versus AFTER-LINE, LINE-NUMBER usage, FIRST-DETAIL patterns, interaction with REPORT-INPUT, and common beginner mistakes mixing detail hooks with break hooks.
Broadcom Language Reference format is the reserved label BEFORE-LINE followed by PROC. Body contains Activity statements; END-PROC closes the procedure. Period after PROC label follows standard procedure naming grammar documented in PROC statement chapter.
12345BEFORE-LINE. PROC IF PAY-NET LT 0 PAY-NET = 0 END-IF END-PROC
For each record PRINT selects, report processing may run REPORT-INPUT, then BEFORE-LINE, then print LINE layout, then AFTER-LINE. BEFORE-LINE is the last opportunity to alter field values that LINE references. Calculations that affect break totals should occur in JOB logic or REPORT-INPUT before accumulation—not only in BEFORE-LINE after sums may have consumed prior values.
| Procedure | When invoked | Typical use |
|---|---|---|
| BEFORE-LINE | Before each detail line | |
| AFTER-LINE | After each detail line | |
| BEFORE-BREAK | Before summary lines | |
| AFTER-BREAK | After summary lines |
When REPORT specifies multiple LINE statements as a group, each physical print row gets its own BEFORE-LINE invocation. LINE-NUMBER holds the index of the line within the group—useful when line two needs different logic than line one on the same selected record. Test multi-line reports with DISPLAY of LINE-NUMBER during development then remove diagnostics before production.
1234567891011REPORT SALES-RPT LINESIZE 132 SEQUENCE REGION REP-NAME LINE 01 REP-NAME REGION GROSS-COMM BEFORE-LINE. PROC IF GROSS-COMM LT MIN-COMM FLAG-LINE = '** BELOW MINIMUM **' ELSE FLAG-LINE = SPACE END-IF END-PROC
Sites porting IBM documentation may use FIRST-DETAIL inside BEFORE-DETAIL procedures to detect first detail after control break or page overflow—useful for repeating headers or stamp dates only once per page. Broadcom 11.6 emphasizes BEFORE-LINE and field-class break tests such as DEPT BREAK. Combine IF FIRST-DETAIL or equivalent with SYSDATE assignment for run date on first detail line only. Verify keyword availability on your compiler—see deprecated constants tutorial for BEFORE-DETAIL migration.
REPORT-INPUT runs when a record is selected for the report—before detail line construction. Use REPORT-INPUT for additional SELECT filtering or moving values into report work fields. Use BEFORE-LINE for last-millisecond display tweaks on the line about to print. Splitting concerns keeps REPORT-INPUT focused on data acceptance and BEFORE-LINE on presentation.
Broadcom notes BEFORE-LINE can print literal strings before a detail line or change detail contents. DISPLAY to SYSPRINT during BEFORE-LINE floods diagnostic output—use sparingly. Prefer modifying LINE fields or dedicated annotation columns defined on LINE layout.
File GET and PUT may be restricted inside report PROCs depending on sort and report context. Avoid heavy I/O in BEFORE-LINE—keep per-row work CPU-light because it runs for every detail line on large extracts. Recursion and PERFORM of other PROCs follow general report PROC rules in your release manual.
BEFORE-LINE is the last look at each row before the printer draws it. Like checking your homework one more time before the teacher reads it aloud. The report robot calls this automatically for every row—not you. You put the checking steps inside BEFORE-LINE recipe. AFTER-LINE is what you do right after the row appears on paper.
1. BEFORE-LINE. PROC runs:
2. LINE-NUMBER system field contains:
3. BEFORE-LINE is invoked by:
4. Legacy BEFORE-DETAIL naming should migrate to:
5. BEFORE-LINE is the last chance to: