Code for Program to print account report in Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. ACCOUNTS-RPT.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE-READ ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT FILE-WRITE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD FILE-READ
VALUE OF FILE-ID IS "ACCOUNTS.MST".
01 F-REC-IN.
02 ACNO-IN PIC 9(5).
02 NAME-IN PIC X(25).
02 DATE1-IN.
05 DD1-IN PIC 99.
05 MM1-IN PIC 99.
05 YY1-IN PIC 99.
02 GENDER-IN PIC X.
FD FILE-WRITE
VALUE OF FILE-ID IS "ACCOUNTS.RPT".
01 F-REC-OUT PIC X(80).
WORKING-STORAGE SECTION.
* 1 2 3 4
*123456789 123456789 123456789 123456789 123456789
* Month Month Total
* No. Name. A/C
01 HEAD-LINE1 PIC X(80)
VALUE " Month Month Total".
01 HEAD-LINE2 PIC X(80)
VALUE " No. Name. A/C".
01 DASH-LINE PIC X(77) VALUE ALL "-".
01 REC-OUT.
02 PIC X(20).
02 MM1-OUT PIC Z9.
02 PIC X(8).
02 MONTH-OUT PIC X(11).
02 TOTAL-AC-OUT PIC Z9.
77 EOF PIC X VALUE 'N'.
77 TOTAL-AC-TMP PIC 99 VALUE ZEROS OCCURS 12 TIMES.
77 COUNTER PIC 99 VALUE 1.
PROCEDURE DIVISION.
BEGIN.
OPEN INPUT FILE-READ.
OPEN OUTPUT FILE-WRITE.
PERFORM HEADING-PARA.
PERFORM UNTIL EOF = 'Y'
READ FILE-READ
AT END MOVE 'Y' TO EOF
NOT AT END PERFORM PROCESS-PARA
END-PERFORM.
PERFORM MOVE-PARA.
WRITE F-REC-OUT FROM DASH-LINE.
CLOSE FILE-READ.
CLOSE FILE-WRITE.
STOP RUN.
HEADING-PARA.
WRITE F-REC-OUT FROM HEAD-LINE1.
WRITE F-REC-OUT FROM HEAD-LINE2.
WRITE F-REC-OUT FROM DASH-LINE.
PROCESS-PARA.
* IF YY1-IN = 2001
EVALUATE MM1-IN
WHEN 01
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 02
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 03
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 04
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 05
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 06
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 07
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 08
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 09
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 10
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 11
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
WHEN 12
ADD 1 TO TOTAL-AC-TMP (MM1-IN)
END-EVALUATE.
* END-IF.
MOVE-PARA.
PERFORM 12 TIMES
EVALUATE COUNTER
WHEN 01
MOVE COUNTER TO MM1-OUT
MOVE "January" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 02
MOVE COUNTER TO MM1-OUT
MOVE "February" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 03
MOVE COUNTER TO MM1-OUT
MOVE "March" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 04
MOVE COUNTER TO MM1-OUT
MOVE "April" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 05
MOVE COUNTER TO MM1-OUT
MOVE "May" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 06
MOVE COUNTER TO MM1-OUT
MOVE "June" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 07
MOVE COUNTER TO MM1-OUT
MOVE "July" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 08
MOVE COUNTER TO MM1-OUT
MOVE "August" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 09
MOVE COUNTER TO MM1-OUT
MOVE "September" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 10
MOVE COUNTER TO MM1-OUT
MOVE "October" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 11
MOVE COUNTER TO MM1-OUT
MOVE "November" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
WHEN 12
MOVE COUNTER TO MM1-OUT
MOVE "December" TO MONTH-OUT
MOVE TOTAL-AC-TMP (COUNTER) TO TOTAL-AC-OUT
WRITE F-REC-OUT FROM REC-OUT
ADD 1 TO COUNTER
END-EVALUATE
END-PERFORM.