May 2007 Technical Tip – Page Break Logic and PL/I
Sometimes associates receive training in a subject long before they need it. Today I had a former student ask me to explain page break logic and to demonstrate how it is done in PL/I. Here is the explanation I gave her...
When declaring the report file, be sure to specify the PRINT option as this is required if subsequent PUT statements are to use the PAGE option (explained below):
Page break logic requires three variables: one for the current page number, one for the actual number of lines printed on the current page, and one for the maximum number of lines allowed on a page. (I usually use 50 as a maximum; your number may vary.)
Before printing a line, check to see if the page is full. If so then print a new set of headings:
Increment the line counter after each PUT statement:
Within the headings routine, increment the page count, write the heading line(s) (one of which will usually include the page count), then reset the line count. The PAGE option on the PUT statement causes the page break to occur.
Some people count the headings lines themselves, so the reinitialization might be LNS = 5 but I figure "headings are free" and use LNS = 0 instead.
The mainframe is alive and well! PL/I, COBOL, Assembler, CICS or JCL: we hope you will consider Caliber Data Training when deciding upon a mainframe training provider.