Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol Paging

Status
Not open for further replies.

sbcoope

Programmer
Joined
Mar 29, 2003
Messages
1
Location
US
I cannot figure out how to make a page having page breaks. I need to have 25 lines then a new page with a heading, etc...
 
Count the lines as you print them. When the line count hits 25, print the headers.

FD ...
01 REPORT-LINE.
03 RL-CARRIAGE-CONTROL PIC 9(01).
03 RL-DATA PIC X(132).

03 AA-LINE-COUNT VALUE +99 PIC S9(02).
88 AA-FULL-PAGE VALUES +25 THRU +99.

03 SA-REPORT-LINE PIC X(133).


9000-WRITE-A-LINE.
IF AA-FULL-PAGE
MOVE REPORT-LINE TO SA-REPORT-LINE
PERFORM 9010-WRITE-HEADERS
THRU 9010-EXIT
MOVE SA-REPORT-LINE TO REPORT-LINE
END-IF.
PERFORM 9020-WRITE
THRU 9020-EXIT.
9000-EXIT.
EXIT.

9010-WRITE-HEADERS.
MOVE header-1 TO RL-DATA.
WRITE REPORT-LINE AFTER ADVANCING PAGE.
MOVE +1 TO AA-LINE-COUNT.
MOVE 2 TO RL-CARRIAGE-CONTROL.
MOVE header-2 TO RL-DATA.
PERFORM 9020-WRITE
THRU 9020-EXIT.
.
.
.
9010-EXIT.
EXIT.

9020-WRITE.
ADD RL-CARRIAGE-CONTROL TO AA-LINE-COUNT.
WRITE REPORT-LINE
AFTER ADVANCING RL-CARRIAGE-CONTROL.
9020-EXIT.
EXIT.

With the initializing of AA-LINE-COUNT to +99, headers automatically get produced when you try to write the first line. You only need one central place to check for headers with this arrangement.
 
Lunker -

Your approach is generally the one I use. I do have one comment. I suspect you're running on an IBM mainframe where the first byte of any file written to with the "ADVANCING" phrase is used as carriage control (depending on the ADV/NOADV option).

For most other COBOLs, the print line should be only what is printed and the data item containing the advancing information should be located elsewhere (likely in WORKING-STORAGE somewhere).

Regards.

Glenn
 
You are right, Glenn. I work on an IBM mainframe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top