Programming Assignment  - page breaks and system date

Modify your previous lab (summary report) to include page breaks (go to a new page after 45 records), and put the page number and the date on the heading line and list all records.  It will take approximately 4 pages of output.

 

To accomplish the date- you will need some code like this:

01  WS-DATE.
	05 THIS-DATE.
            10 CURRENT-YEAR       PIC 9999.
            10 CURRENT-MONTH      PIC 99.
            10 CURRENT-DAY        PIC 99.
        05  THIS-TIME             PIC X(23).
(check index for 'intrinic functions')

and in the procedure division - in the initialize module:

	MOVE FUNCTION CURRENT-DATE TO WS-DATE
and:
      MOVE CURRENT-YEAR TO YEAR-OUT
      MOVE CURRENT-MONTH TO MONTH-OUT
      MOVE CURRENT-DAY   TO DAY-OUT
You will also need to modify your heading line to 
be like this:  
11/03/2001            WHITE CORPORATION            PAGE  1
01  HEADING-LINE-1.
	05			PIC X(05) VALUE SPACES.
	05 MONTH-OUT		PIC 99.
	05			PIC X VALUE "/".
	05 DAY-OUT		PIC 99.
	05			PIC X VALUE "/".
	05 YEAR-OUT		PIC 9999.
	05			PIC X(15) VALUE SPACES.
	05			PIC X(30) VALUE "WHITE CORPORATION".
	05			PIC X(05) VALUE "PAGE".
	05 PAGE-NUMBER-OUT	PIC Z9.

You will also need at least two additional counters -


	05 LINE-CTR		PIC 99 VALUE ZERO.
	05 PAGE-LIMIT	PIC 99 VALUE 45.
      05 PAGE-NUMBER	PIC 99 VALUE ZERO.

Each time when you write out a detail line, you will add 1 to the LINE-CTR - when the LINE-CTR gets larger than than the page-limit, you will want to go to a heading routine and add 1 to the page-number and write the heading line after advancing page. (see the section in chapter 6 on headings, date and time)

Note - this WILL use the AFTER ADVANCING PAGE option on the WRITE statement.  This causes COBOL to send the output to a  new page.  To correctly see your output, you may want to open your output file in Microsoft Word to see if it correctly went to a new page.  The AFTER ADVANCING option is also used to double space output (like WRITE REPORT-RECORD FROM DETAIL-LINE AFTER ADVANCING 2).  

Second note:  If you look at the output in notepad, you will have weird symbols - like little boxes where the new page routines are at.  

My sample output:  

The data file:

Optional data file (sorted by last name):

Back to Main Menu