PRINT is the bridge between file processing and report layout. Inside the JOB loop you test business rules; when a record should appear on paper, you PRINT it. Easytrieve copies the fields the report needs into a work structure and later formats titles, headings, detail lines, and totals. That deferred path is why PRINT feels different from DISPLAY: DISPLAY shouts a line now; PRINT files a request for the report writer. This chapter page focuses on PRINT as a report selection tool—syntax, default versus named reports, IF patterns, dual-report jobs, interaction with CONTROL breaks, work-file behavior, and testing—so beginners stop treating PRINT as a mysterious synonym for "print everything."
123PRINT PRINT PAY-RPT PRINT EXCEPT-RPT
Bare PRINT sends the current record to the first report in the JOB activity—ideal for single-report programs. PRINT PAY-RPT targets the REPORT named PAY-RPT. Report-names must match the REPORT declaration exactly. Spelling mismatches compile or fail to route output depending on checks; treat names like DD names: short, unique, and consistent.
1234567JOB INPUT PERSNL IF GROSS GE 50000 PRINT HIGH-EARNERS END-IF IF STATUS EQ 'T' PRINT TERM-LIST END-IF
One input pass can feed two reports with different rules. High earners go to HIGH-EARNERS; terminated employees go to TERM-LIST. A person who matches both gets two PRINT calls and appears on both reports. A person who matches neither is skipped—selection is explicit. Beginners who PRINT every record and hope REPORT filters later miss the point: REPORT formats what PRINT already chose.
| Verb | Timing | Formatting | Best use |
|---|---|---|---|
| Deferred | REPORT titles, LINE, breaks | Finished listings | |
| DISPLAY | Immediate | Raw line | Messages, debug, counters |
| PUT | Immediate file write | Record layout | Extracts and feeds |
| WRITE | Immediate VSAM/update | File record | Master maintenance |
Use PRINT when humans will read structured pages. Use DISPLAY when operators need a live message. Use PUT when another program will read fixed columns. Using PRINT as a cheap PUT creates irregular spacing and title noise in interface files.
When PRINT executes, Easytrieve gathers the field values required by that report's LINE, TITLE field items, CONTROL fields, and related items—typically into a work-file record. Later formatting reads those snapshots. If you change a working-storage field after PRINT, that PRINT's work record already holds the earlier value. If you need a calculated field on the report, assign it before PRINT. Virtual W fields used on reports also depend on PRINT timing relative to assignment; see the virtual-fields tutorial for spool timing details.
1234567891011121314JOB INPUT CLAIMS IF ERROR-FLAG EQ 'Y' PRINT BAD ELSE PRINT GOOD END-IF REPORT GOOD LINESIZE 132 TITLE 01 'VALID CLAIMS' LINE 01 CLAIM-NO AMOUNT REPORT BAD LINESIZE 132 TITLE 01 'REJECTED CLAIMS' LINE 01 CLAIM-NO ERR-CODE ERR-MSG
CONTROL lives on REPORT, not on PRINT. You still PRINT every detail row you want included. During formatting, Easytrieve compares CONTROL field values across successive work records. When DEPT changes, it prints the department total line, then continues. Skipping PRINT for some rows removes them from both detail and break math. Printing only summary candidates without detail is a different design—usually you PRINT details and let CONTROL produce summaries, or you build a separate summary report with its own PRINT rules.
JOB INPUT PERSNL with a bare PRINT every iteration lists the entire file. That is valid for full dumps. Add IF filters as soon as the business asks for subsets. JOB INPUT NULL with GET still uses PRINT the same way after each successful GET and EOF test. PROGRAM activities can PRINT too when they maintain buffers manually—always ensure fields are populated before PRINT.
Every PRINT can write a work-file record. Printing millions of rows is fine when needed, but filtering early reduces work-file size and sort cost if SEQUENCE is coded. Prefer IF before PRINT over printing everything and hiding rows with empty LINE tricks. For huge volumes, REPORT FILE pointing at a large sequential work dataset may be required by site standards.
PRINT is like putting a sticker on a homework paper that says "include this in the class booklet." You only sticker the papers that should go in. Later, the booklet machine (REPORT) lines up all stickered papers, puts a cover on each page (TITLE), writes column names (HEADING), and writes each paper's answers in neat rows (LINE). DISPLAY is shouting one answer out loud right now instead of waiting for the booklet.
1. PRINT without a report-name uses:
2. With two REPORT declarations, PRINT should:
3. PRINT output is typically:
4. Where do you usually code PRINT?
5. Control breaks during report formatting are driven by: