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.
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).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.