Easytrieve PRINT for Reports

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."

Progress0 of 0 lessons

Statement Forms

text
1
2
3
PRINT 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.

Selection Pattern: IF Then PRINT

text
1
2
3
4
5
6
7
JOB 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.

PRINT Versus What Else Writes Output

Output verbs compared for report writers
VerbTimingFormattingBest use
PRINTDeferredREPORT titles, LINE, breaksFinished listings
DISPLAYImmediateRaw lineMessages, debug, counters
PUTImmediate file writeRecord layoutExtracts and feeds
WRITEImmediate VSAM/updateFile recordMaster 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.

What PRINT Captures

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.

Multiple Reports Checklist

  1. Declare REPORT DETAIL and REPORT EXCEPT (names required for the second and beyond).
  2. Give each its own TITLE and LINE layout.
  3. Optionally set FILE printer-dd on each REPORT to split spool destinations.
  4. Code PRINT DETAIL or PRINT EXCEPT in the matching IF branches.
  5. Never assume bare PRINT reaches the second report.
text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
JOB 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

PRINT and Control Breaks

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.

Automatic Input and Unconditional PRINT

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.

Empty Reports and Debugging

  • DISPLAY a counter each time you PRINT to prove selection fired.
  • Temporarily remove IF to see if REPORT/LINE produce any pages.
  • Verify report-name spelling on PRINT and REPORT.
  • Check printer FILE DD and SYSOUT class in JCL.
  • Confirm SEQUENCE/CONTROL did not confuse you into thinking PRINT failed when totals look odd.

Performance Notes

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.

Common PRINT Mistakes

  • PRINT without REPORT/LINE in the activity.
  • Wrong report-name with multiple reports.
  • Assigning report fields after PRINT.
  • Using PRINT instead of PUT for fixed extracts.
  • Expecting PRINT to sort without SEQUENCE or prior SORT.
  • Forgetting EOF checks in manual GET loops before PRINT.

Explain It Like I'm Five

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.

Exercises

  1. Write IF GROSS GT 10000 PRINT BONUS-RPT with a matching REPORT.
  2. Design GOOD and BAD reports with two PRINT names from one JOB INPUT.
  3. Explain deferred work-file capture in your own words.
  4. List three reasons a report page count might be zero.
  5. Compare PRINT and DISPLAY for showing a running total mid-job.

Quiz

Test Your Knowledge

1. PRINT without a report-name uses:

  • The first report in the JOB activity
  • Always SYSOUT class A only
  • The last FILE statement
  • SCREEN TITLE

2. With two REPORT declarations, PRINT should:

  • Name the target report on each PRINT
  • Never name reports
  • Replace REPORT with DISPLAY
  • Use only GET

3. PRINT output is typically:

  • Deferred and formatted by REPORT
  • Identical to immediate DISPLAY
  • Written only to VSAM
  • Ignored if TITLE exists

4. Where do you usually code PRINT?

  • Inside JOB logic after deciding the record qualifies
  • Only after END of the entire program
  • Inside TITLE statements
  • In JCL only

5. Control breaks during report formatting are driven by:

  • CONTROL fields as PRINT-fed records are formatted
  • PRINT alone without CONTROL
  • Only MACRO expansion
  • STEPLIB order

Related Pages

Published
Read time17 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 PRINT and report work file behaviorSources: Broadcom Easytrieve 11.6 Language Reference PRINT, REPORTApplies to: Easytrieve report selection with PRINT