How to do a two dimensional table (array) and fix errors - cobol

My outputs are not getting out right, and I'm not too sure how to go about doing a two dimensional array.
I have my outputs follow by the outputs should look like.....
Good example how to set up 2 dimensional table would help, since not sure what I find on line is good plus haven't found a good enough book to explain to an old person terms.
First is my code:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO DATAIN
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTPUT-FILE ASSIGN TO DATAOUT
ORGANIZATION IS LINE SEQUENTIAL.
SELECT ERROR-FILE ASSIGN TO DATAOUT2
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
*-------------------------------------------------------------*
* INPUT FILE LAYOUT *
*-------------------------------------------------------------*
FD INPUT-FILE.
01 INPUT-RECORD.
05 IR-JOB-NUM PIC 9(02).
88 IR-JOB-NUM-VALID VALUE 01 THRU 11.
05 IR-EMP-NUM PIC 9(01).
88 IR-EMP-NUM-VALID VALUE 1 THRU 4.
05 IR-NUM-COMPLETE PIC 9(04).
05 FILLER PIC X(03).
05 FILLER PIC X(07).
*-------------------------------------------------------------*
* OUTPUT FILE *
*-------------------------------------------------------------*
FD OUTPUT-FILE.
01 OUTPUT-RECORD PIC X(80).
*-------------------------------------------------------------*
* ERROR FILE *
*-------------------------------------------------------------*
FD ERROR-FILE.
01 ERROR-RECORD PIC X(80).
*-------------------------------------------------------------*
* WORKING STORAGE SECTION *
*-------------------------------------------------------------*
WORKING-STORAGE SECTION.
01 FLAGS-AND-ACCUMALATORS.
05 END-OF-FILE PIC XXX VALUE "NO".
88 AT-END-OF-FILE VALUE "YES".
05 ERROR-FLAG PIC XXX VALUE "NO".
05 BLANK-LINE PIC X(80) VALUE SPACES.
05 LINE-NUM-IR-POSITION PIC 999 VALUE ZERO.
01 SUBSCRIPT.
05 SUB PIC 99 VALUE ZERO.
*---------------------------------------------------------------*
* REPORT STRUCTURE *
*---------------------------------------------------------------*
* ERROR HEADER RECORD *
01 ER-HEADER.
05 FILLER PIC X(08) VALUE SPACES.
05 FILLER PIC X(03) VALUE "NO.".
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(06) VALUE "RECORD".
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(05) VALUE "ABOVE".
05 FILLER PIC X(33) VALUE SPACES.
* ERROR DETAIL RECORD *
01 ER-DETAIL-LINE.
05 FILLER PIC X(06) VALUE SPACES.
05 DL-ASTERIK PIC X(01) VALUE SPACES.
05 FILLER PIC X(01) VALUE SPACES.
05 DL-LINE-NUM PIC ZZ9 VALUE SPACES.
05 FILLER PIC X(09) VALUE SPACES.
05 DL-ERROR PIC X(16) VALUE SPACES.
05 FILLER PIC X(09) VALUE SPACES.
05 DL-ERROR-BIG-NUM PIC ZZZ9 VALUE SPACES.
* ERROR ERROR RECORD *
01 ER-ERROR-LINE.
05 FILLER PIC X(20) VALUE SPACES.
05 EL-JOB-NUM PIC X(02) VALUE SPACES.
05 EL-EMP-NUM PIC X(01) VALUE SPACES.
05 EL-NUM-COMPLETE PIC X(03) VALUE SPACES.
05 FILLER PIC X(54) VALUE SPACES.
* OUTPUT HEADER RECORD *
01 OR-HEADER.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(03) VALUE "NO.".
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(08) VALUE "LOCATION".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 1 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 2 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 3 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 4 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE "TOTAL".
05 FILLER PIC X(15) VALUE SPACES.
* OUTPUT DETAIL RECORD *
01 OR-DETAIL-LINE.
03 OR-DETAIL OCCURS 11 TIMES.
05 FILLER PIC X(02) VALUE SPACES.
05 OR-JOB-NUM PIC 9(02).
05 FILLER PIC X(03) VALUE SPACES.
05 OR-LOCATION PIC X(08) VALUE "XXXXXXXX".
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP1-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP2-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP3-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP4-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-JOB-TOT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(15) VALUE SPACES.
* SUMMARY RECORD *
01 OR-SUMMARY.
05 FILLER PIC X(08) VALUE SPACES.
05 FILLER PIC X(06)
VALUE "TOTALS".
05 FILLER PIC X(04) VALUE SPACES.
05 OR-TOT1-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT2-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT3-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT4-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT-TOT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(15) VALUE SPACES.
PROCEDURE DIVISION.
*****************************************************************
*0000-MAIN-PROCEDURE *
*****************************************************************
0000-MAIN-PROCEDURE SECTION.
OPEN INPUT INPUT-FILE
OUTPUT OUTPUT-FILE
ERROR-FILE.
PERFORM 1000-INITIALIZE.
PERFORM UNTIL AT-END-OF-FILE
READ INPUT-FILE
AT END
MOVE 'YES' TO END-OF-FILE
NOT AT END
PERFORM 2000-PROCESS
END-READ
END-PERFORM.
PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 11
PERFORM 3000-FINALIZE
END-PERFORM.
PERFORM 4000-SUMMARY.
CLOSE INPUT-FILE
OUTPUT-FILE
ERROR-FILE.
GOBACK.
0000-EXIT.
EXIT.
/
*****************************************************************
*1000-INITIALIZE *
*****************************************************************
*PURPOSE: INITIALIZE ALL THE VARIABLES AND *
* WRITE THE HEADER RECORDS TO THE OUTPUT FILES. *
*****************************************************************
1000-INITIALIZE SECTION.
WRITE ERROR-RECORD FROM ER-HEADER.
WRITE ERROR-RECORD FROM BLANK-LINE.
WRITE OUTPUT-RECORD FROM OR-HEADER.
WRITE OUTPUT-RECORD FROM BLANK-LINE.
1000-EXIT.
EXIT.
/
2000-PROCESS SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
MOVE 'NO' TO ERROR-FLAG.
ADD 1 TO LINE-NUM-IR-POSITION.
IF NOT IR-JOB-NUM-VALID
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-JOB-NUM
END-IF.
IF NOT IR-EMP-NUM-VALID
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-EMP-NUM
END-IF.
IF ERROR-FLAG = 'NO'
INSPECT IR-NUM-COMPLETE REPLACING LEADING
SPACES BY ZEROES
IF IR-NUM-COMPLETE IS NUMERIC
MOVE IR-JOB-NUM TO SUB
IF IR-EMP-NUM = 1
ADD IR-NUM-COMPLETE TO
OR-EMP1-AMT(SUB)
END-IF
IF IR-EMP-NUM = 2
ADD IR-NUM-COMPLETE TO
OR-EMP2-AMT(SUB)
END-IF
IF IR-EMP-NUM = 3
ADD IR-NUM-COMPLETE TO
OR-EMP3-AMT(SUB)
END-IF
IF IR-EMP-NUM = 4
ADD IR-NUM-COMPLETE TO
OR-EMP4-AMT(SUB)
END-IF
ELSE
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-NUM-COMPLETE
END-IF.
IF ERROR-FLAG = 'YES'
IF IR-NUM-COMPLETE > 50
MOVE ALL '*' TO DL-ASTERIK
MOVE IR-NUM-COMPLETE TO DL-ERROR-BIG-NUM
END-IF
WRITE ERROR-RECORD FROM ER-DETAIL-LINE
WRITE ERROR-RECORD FROM ER-ERROR-LINE
MOVE SPACES TO ER-DETAIL-LINE
MOVE SPACES TO ER-ERROR-LINE
END-IF.
2000-EXIT.
EXIT.
/
3000-FINALIZE SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
MOVE SUB TO OR-JOB-NUM(SUB).
ADD OR-EMP1-AMT(SUB)
OR-EMP2-AMT(SUB)
OR-EMP3-AMT(SUB)
TO OR-EMP4-AMT(SUB)
GIVING OR-JOB-TOT(SUB).
ADD OR-EMP1-AMT(SUB) TO OR-TOT1-AMT.
ADD OR-EMP2-AMT(SUB) TO OR-TOT2-AMT.
ADD OR-EMP3-AMT(SUB) TO OR-TOT3-AMT.
ADD OR-EMP4-AMT(SUB) TO OR-TOT4-AMT.
ADD OR-JOB-TOT(SUB) TO OR-TOT-TOT.
IF OR-JOB-TOT(SUB) > 0
WRITE OUTPUT-RECORD FROM OR-DETAIL(SUB)
WRITE OUTPUT-RECORD FROM BLANK-LINE
END-IF.
3000-EXIT.
EXIT.
/
4000-SUMMARY SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
WRITE OUTPUT-RECORD FROM BLANK-LINE.
WRITE OUTPUT-RECORD FROM OR-SUMMARY.
4000-EXIT.
EXIT.
My output in the Exception report is:
NO. RECORD ABOVE
3 0r4000700 03
**
6 074000Q00 06
***
* 7 075075000 07 750
*
* 8 06105 100 08 5 1
***
10 095000500 10
*
* 12 125999999 12 9999
***
19 08500050 19
*
21 125000899 21
***
23 A01001111 23
**
But should be:
ERROR REPORT
NO. CONTENTS ABOVE
2 032 200 02
****
3 0r4000700 03
**
5 073 73000 05
****
6 074000Q00 06
****
* 7 075075000 07 750
*
8 06105 100 08
****
9 011 52000 09
****
10 095000500 10
*
* 12 125999999 12 9999
***
19 08500050 19
*
* 20 091010000 20 100
21 125000899 21
***
23 A01001111 23
**
And my output for summary is:
NO. LOCATION 1 2 3 4 TOTAL
01 XXXXXXXX 00520 00000 00000 00000 00520
03 XXXXXXXX 00000 00002 00000 00007 00009
04 XXXXXXXX 00010 00010 00003 00000 00023
05 XXXXXXXX 00000 00012 00000 00004 00016
06 XXXXXXXX 00000 00000 00000 00004 00004
07 XXXXXXXX 00000 00000 00730 00000 00730
08 XXXXXXXX 00006 00000 00000 00004 00010
09 XXXXXXXX 00100 00000 00000 00000 00100
TOTALS 00636 00024 00733 00019 01412
And should look like this:
SUMMARY REPORT
NO. LOCATION 1 2 3 4 TOTAL
1 PETERS, FL 0 0 0 0 0
2 ATCHISON, KS 0 0 0 0 0
3 KANSAS CITY, MO 0 0 0 7 7
4 DENVER, CO 10 10 3 0 23
5 SAN JOSE, CA 0 12 0 4 16
6 REDMOND, WA 0 0 0 4 4
7 HOUSTON, TX 0 0 0 0 0
8 TOPEKA, KS 6 0 0 4 10
9 WICHITA, KS 100 0 0 0 100
10 JEFFERSON CITY, MO 0 0 0 0 0
11 ST. LOUIS MO 0 0 0 0 0
TOTALS 116 22 3 19 160

For Multi dimensional arrays in Cobol, just nest the occurs clause:
01 WS-DETAIL-totals OCCURS 11 TIMES.
05 WS-JOB-NUM PIC 9(02).
05 WS-LOCATION PIC X(08) VALUE "XXXXXXXX".
05 WS-EMP-AMT occurs 4 PIC s9(05) COMP VALUE ZEROES.
05 WS-JOB-TOT PIC s9(05) COMP VALUE ZEROES.
01 OR-DETAIL-LINE.
03 OR-DETAIL OCCURS 11 TIMES.
05 FILLER PIC X(02) VALUE SPACES.
05 OR-JOB-NUM PIC z9.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-LOCATION PIC X(08) VALUE "XXXXXXXX".
05 FILLER PIC X(03) VALUE SPACES.
05 Filler occurs 4.
10 OR-EMP1-AMT PIC ----9.
10 FILLER PIC X(03) VALUE SPACES.
05 OR-JOB-TOT PIC ----9 VALUE ZEROES.
05 FILLER PIC X(15) VALUE SPACES.
You should also accumulate in comp fields (like in ws table above) and move to output table.
The
INSPECT IR-NUM-COMPLETE REPLACING LEADING
SPACES BY ZEROES
statement in 2000- means errors like the following are not caught
2 032 200 02
****

Related

How do I fix a program bypass that is not working?

I have a program that works perfectly except when reading in the SEQ file it is suppose to skip/bypass the record entirely then move on to the next one in the file. It is suppose to bypass the input file if the student has graduated (skip Graduation Status if equal to 'Y'). Bypass if Class Standing is anything other than '1' or '2'. Lastly, bypass if Major is not 'DIG', 'NES', or 'PGM'. I have a Bypass in the program under 120-CHECK-BYPASS. but it is not sorting/stopping any records from processing. How do I fix this?
Program:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STUDENTS-FILE-IN
ASSIGN TO 'STUDENTS.SEQ'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT STUDENTS-FILE-OUT
ASSIGN TO 'STUDENTS.RPT'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD STUDENTS-FILE-IN.
01 STUDENTS-RECORD-IN.
05 SOCIAL-SECURITY-NUMBER-FIRST-IN PIC X(3).
05 SOCIAL-SECURITY-NUMBER-MIDDLE-IN PIC X(2).
05 SOCIAL-SECURITY-NUMBER-LAST-IN PIC X(4).
05 STUDENT-NAME-FIRST-IN PIC X.
05 STUDENT-NAME-MIDDLE-IN PIC X.
05 STUDENT-NAME-LAST-IN PIC X(9).
05 PIC X(5).
05 GRADUATION-STATUS-IN PIC X.
05 CLASS-STANDING-IN PIC X.
05 MAJOR-IN PIC X(3).
05 CREDIT-HOURS-EARNED-IN PIC 9(3).
05 CREDIT-POINTS-EARNED-IN PIC 9(3).
FD STUDENTS-FILE-OUT.
01 STUDENTS-RECORD-OUT PIC X(80).
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
01 LINES-PRINTED PIC 99 VALUE 99.
01 PAGE-NUMBER PIC 99 VALUE ZERO.
01 WS-FIRST-TIME-THRU PIC X(3) VALUE 'YES'.
01 WS-GPA PIC Z.ZZ VALUE ZERO.
01 WS-GRAND-HOURS PIC 9(7) VALUE ZERO.
01 WS-GRAND-POINTS PIC 9(7) VALUE ZERO.
01 WS-GRAND-GPA PIC Z.ZZ VALUE ZERO.
01 WS-PRO-STUDENT PIC 9(2) VALUE ZERO.
01 WS-GRAND-PRO-STUDENT PIC 99V9 VALUE ZERO.
01 WS-PRO-GPA-NUM PIC 99 VALUE ZERO.
01 WS-DIG-STUDENT PIC 99 VALUE ZERO.
01 WS-DIG-GPA-NUM PIC 99 VALUE ZERO.
01 WS-GRAND-DIG-STUDENT PIC 99V9 VALUE ZERO.
01 WS-GRAND-NES-STUDENT PIC 99V9 VALUE ZERO.
01 WS-NES-STUDENT PIC 99 VALUE ZERO.
01 WS-NES-GPA-NUM PIC 99 VALUE ZERO.
01 WS-OTHER PIC 99 VALUE ZERO.
01 WS-CURRENT-DATE-DATA.
05 WS-CURRENT-DATE.
10 RUN-YEAR PIC XX.
10 RUN-MONTH PIC XX.
10 RUN-DAY PIC XX.
01 HEADING-LINE-1.
05 PIC X(22) VALUE SPACES.
05 PIC X(33) VALUE '------ ----- ------- ----- ------'.
05 PIC X(6) VALUE SPACES.
05 HL-1-DATE.
10 MONTH-2 PIC XX.
10 PIC X VALUE'/'.
10 DAY-2 PIC XX.
10 PIC X VALUE'/'.
10 YEAR-2 PIC XX.
05 PIC X(4) VALUE SPACES.
05 PIC X(4) VALUE 'PAGE'.
05 HL-1-PAGE-NUMBER PIC Z9.
01 HEADING-LINE-2.
05 PIC X VALUE SPACE.
05 PIC X(10) VALUE 'SOC SEC NO'.
05 PIC X(4) VALUE SPACES.
05 PIC X(12) VALUE 'STUDENT NAME'.
05 PIC X(3) VALUE SPACES.
05 PIC X(8) VALUE 'STANDING'.
05 PIC X(4) VALUE SPACES.
05 PIC X(5) VALUE 'MAJOR'.
05 PIC X(10) VALUE SPACES.
05 PIC X(5) VALUE 'HOURS'.
05 PIC X(2) VALUE SPACES.
05 PIC X(6) VALUE 'POINTS'.
05 PIC X(5) VALUE SPACES.
05 PIC X(3) VALUE 'GPA'.
01 DETAIL-LINE.
05 PIC X VALUE SPACE.
05 SOCIAL-SECURITY-NUMBER-FIRST-OUT PIC X(3).
05 SSN-FDASH PIC X VALUE "-".
05 SOCIAL-SECURITY-NUMBER-MIDDLE-OUT PIC X(2).
05 SSN-MDASH PIC X VALUE "-".
05 SOCIAL-SECURITY-NUMBER-LAST-OUT PIC X(4).
05 PIC X(3) VALUE SPACES.
05 STUDENT-NAME-FIRST-OUT PIC X.
05 PIC X VALUE SPACE.
05 STUDENT-NAME-MIDDLE-OUT PIC X.
05 PIC X VALUE SPACE.
05 STUDENT-NAME-LAST-OUT PIC X(9).
05 PIC X(2) VALUE SPACES.
05 CLASS-STANDING-OUT PIC X(9).
05 PIC X(3) VALUE SPACES.
05 MAJOR-OUT PIC X(13).
05 PIC X(4) VALUE SPACES.
05 HOURS-OUT PIC ZZZ.
05 PIC X(5) VALUE SPACES.
05 POINTS-OUT PIC ZZZ.
05 PIC X(4) VALUE SPACES.
05 STUDENT-GPA-OUT PIC 9.99.
01 TOTALS-LINE.
05 PIC X VALUE SPACE.
05 PIC X(6) VALUE 'Totals'.
05 PIC X(50) VALUE SPACES.
05 TL-GRAND-HOURS PIC Z,ZZZ.
05 PIC X(2) VALUE SPACES.
05 TL-GRAND-POINTS PIC ZZ,ZZZ.
05 PIC X(4) VALUE SPACES.
05 TL-GRAND-GPA PIC 9.99.
01 TOTALS-LINE-2A.
05 PIC X VALUE SPACE.
05 PIC X(19) VALUE 'Programming Majors:'.
01 TOTALS-LINE-2B.
05 PIC X(5) VALUE SPACES.
05 PIC X(18) VALUE 'Number of students'.
05 PIC X(9) VALUE SPACES.
05 TL-GRAND-PRO-STUDENT PIC X(2).
01 TOTALS-LINE-2C.
05 PIC X(5) VALUE SPACES.
05 PIC X(21) VALUE 'Number with GPA > 3.0'.
05 PIC X(6) VALUE SPACES.
05 TL-GRAND-PRO-NUM-GPA PIC X(2).
01 TOTALS-LINE-2D.
05 PIC X(5) VALUE SPACES.
05 PIC X(22) VALUE 'Percent with GPA > 3.0'.
05 PIC X(5) VALUE SPACES.
05 TL-GRAND-PRO-GPA-PER PIC 99.9.
05 PIC X VALUE '%'.
01 TOTALS-LINE-3A.
05 PIC X VALUE SPACE.
05 PIC X(21) VALUE 'Digital Media Major:'.
01 TOTALS-LINE-3B.
05 PIC X(5) VALUE SPACES.
05 PIC X(18) VALUE 'Number of students'.
05 PIC X(9) VALUE SPACES.
05 TL-GRAND-DIG-STUDENT PIC X(2).
01 TOTALS-LINE-3C.
05 PIC X(5) VALUE SPACES.
05 PIC X(21) VALUE 'Number with GPA > 3.0'.
05 PIC X(6) VALUE SPACES.
05 TL-GRAND-DIG-NUM-GPA PIC XX.
01 TOTALS-LINE-3D.
05 PIC X(5) VALUE SPACES.
05 PIC X(22) VALUE 'Percent with GPA > 3.0'.
05 PIC X(5) VALUE SPACES.
05 TL-GRAND-DIG-GPA-PER PIC 99.9.
05 PIC X VALUE '%'.
01 TOTALS-LINE-4A.
05 PIC X VALUE SPACE.
05 PIC X(24) VALUE 'Network Security Major:'.
01 TOTALS-LINE-4B.
05 PIC X(5) VALUE SPACES.
05 PIC X(18) VALUE 'Number of students'.
05 PIC X(9) VALUE SPACES.
05 TL-GRAND-NET-STUDENT PIC X(2).
01 TOTALS-LINE-4C.
05 PIC X(5) VALUE SPACES.
05 PIC X(21) VALUE 'Number with GPA > 3.0'.
05 PIC X(6) VALUE SPACES.
05 TL-GRAND-NET-NUM-GPA PIC XX.
01 TOTALS-LINE-4D.
05 PIC X(5) VALUE SPACES.
05 PIC X(22) VALUE 'Percent with GPA > 3.0'.
05 PIC X(5) VALUE SPACES.
05 TL-GRAND-NET-GPA-PER PIC ZZ.9.
05 PIC X VALUE '%'.
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT STUDENTS-FILE-IN
OPEN OUTPUT STUDENTS-FILE-OUT
ACCEPT WS-CURRENT-DATE FROM DATE
MOVE RUN-MONTH TO MONTH-2
MOVE RUN-DAY TO DAY-2
MOVE RUN-YEAR TO YEAR-2
PERFORM 300-WRITE-HEADINGS
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO'
READ STUDENTS-FILE-IN
AT END
PERFORM 400-TOTALS-ROUTINE
PERFORM 700-GRAND-TOTALS-PROGRAMMING
PERFORM 800-PRO-GPA
MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 120-CHECK-BYPASS
END-READ
END-PERFORM
CLOSE STUDENTS-FILE-IN
CLOSE STUDENTS-FILE-OUT
STOP RUN.
120-CHECK-BYPASS.
IF GRADUATION-STATUS-IN NOT EQUAL TO 'Y'
AND CLASS-STANDING-IN EQUAL TO '1' OR '2'
AND MAJOR-IN IS EQUAL TO 'DIG' OR 'NES' OR 'PGM'
PERFORM 200-PROCESS-ONE-RECORD
ELSE CONTINUE
END-IF.
200-PROCESS-ONE-RECORD.
IF LINES-PRINTED > 57
PERFORM 300-WRITE-HEADINGS
END-IF
PERFORM 725-PRO-STUDENT-NUM
COMPUTE WS-GPA ROUNDED = CREDIT-POINTS-EARNED-IN / CREDIT-HOURS-EARNED-IN
MOVE SOCIAL-SECURITY-NUMBER-FIRST-IN TO SOCIAL-SECURITY-NUMBER-FIRST-OUT
MOVE SOCIAL-SECURITY-NUMBER-MIDDLE-IN TO SOCIAL-SECURITY-NUMBER-MIDDLE-OUT
MOVE SOCIAL-SECURITY-NUMBER-LAST-IN TO SOCIAL-SECURITY-NUMBER-LAST-OUT
MOVE STUDENT-NAME-FIRST-IN TO STUDENT-NAME-FIRST-OUT
MOVE STUDENT-NAME-MIDDLE-IN TO STUDENT-NAME-MIDDLE-OUT
MOVE STUDENT-NAME-LAST-IN TO STUDENT-NAME-LAST-OUT
MOVE CLASS-STANDING-IN TO CLASS-STANDING-OUT
PERFORM 600-YEAR-PRINT
MOVE MAJOR-IN TO MAJOR-OUT
PERFORM 500-MAJOR-PRINT
MOVE CREDIT-HOURS-EARNED-IN TO HOURS-OUT
MOVE CREDIT-POINTS-EARNED-IN TO POINTS-OUT
MOVE WS-GPA TO STUDENT-GPA-OUT
MOVE DETAIL-LINE TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINES
ADD 2 TO LINES-PRINTED
COMPUTE WS-GRAND-HOURS = WS-GRAND-HOURS + CREDIT-HOURS-EARNED-IN
COMPUTE WS-GRAND-POINTS = WS-GRAND-POINTS + CREDIT-POINTS-EARNED-IN
COMPUTE WS-GRAND-GPA ROUNDED = WS-GRAND-POINTS / WS-GRAND-HOURS
PERFORM 800-PRO-GPA.
300-WRITE-HEADINGS.
ADD 1 TO PAGE-NUMBER
MOVE PAGE-NUMBER TO HL-1-PAGE-NUMBER
MOVE HEADING-LINE-1 TO STUDENTS-RECORD-OUT
IF WS-FIRST-TIME-THRU = 'YES'
WRITE STUDENTS-RECORD-OUT
MOVE 'NO' TO WS-FIRST-TIME-THRU
ELSE
WRITE STUDENTS-RECORD-OUT AFTER ADVANCING PAGE
END-IF
MOVE HEADING-LINE-2 TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 2
MOVE 3 TO LINES-PRINTED.
400-TOTALS-ROUTINE.
IF LINES-PRINTED > 57
PERFORM 300-WRITE-HEADINGS
END-IF
MOVE WS-GRAND-HOURS TO TL-GRAND-HOURS
MOVE WS-GRAND-POINTS TO TL-GRAND-POINTS
MOVE WS-GRAND-GPA TO TL-GRAND-GPA
MOVE TOTALS-LINE TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT AFTER ADVANCING 2 LINES
ADD 2 TO LINES-PRINTED.
500-MAJOR-PRINT.
EVALUATE MAJOR-OUT
WHEN = 'NES'
MOVE 'Net Security' TO MAJOR-OUT
WHEN = 'PGM'
MOVE 'Programming' TO MAJOR-OUT
WHEN = 'DIG'
MOVE 'Digital Media' TO MAJOR-OUT
WHEN OTHER
MOVE '------' TO MAJOR-OUT
END-EVALUATE.
600-YEAR-PRINT.
EVALUATE CLASS-STANDING-OUT
WHEN = '1'
MOVE 'First Yr' TO CLASS-STANDING-OUT
WHEN = '2'
MOVE 'Second Yr' TO CLASS-STANDING-OUT
WHEN OTHER
MOVE '------' TO CLASS-STANDING-OUT
END-EVALUATE.
700-GRAND-TOTALS-PROGRAMMING.
MOVE TOTALS-LINE-2A TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 4 LINES
MOVE WS-PRO-STUDENT TO TL-GRAND-PRO-STUDENT
MOVE TOTALS-LINE-2B TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
MOVE WS-PRO-GPA-NUM TO TL-GRAND-PRO-NUM-GPA
MOVE TOTALS-LINE-2C TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
COMPUTE WS-GRAND-PRO-STUDENT = (WS-PRO-GPA-NUM / WS-PRO-STUDENT) * 100
MOVE WS-GRAND-PRO-STUDENT TO TL-GRAND-PRO-GPA-PER
MOVE TOTALS-LINE-2D TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
MOVE TOTALS-LINE-3A TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 2 LINES
MOVE WS-DIG-STUDENT TO TL-GRAND-DIG-STUDENT
MOVE TOTALS-LINE-3B TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
MOVE WS-DIG-GPA-NUM TO TL-GRAND-DIG-NUM-GPA
MOVE TOTALS-LINE-3C TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
COMPUTE WS-GRAND-DIG-STUDENT = (WS-DIG-GPA-NUM / WS-DIG-STUDENT) * 100
MOVE WS-GRAND-DIG-STUDENT TO TL-GRAND-DIG-GPA-PER
MOVE TOTALS-LINE-3D TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
MOVE TOTALS-LINE-4A TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 2 LINES
MOVE WS-NES-STUDENT TO TL-GRAND-NET-STUDENT
MOVE TOTALS-LINE-4B TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
MOVE WS-NES-GPA-NUM TO TL-GRAND-NET-NUM-GPA
MOVE TOTALS-LINE-4C TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE
COMPUTE WS-GRAND-NES-STUDENT = (WS-NES-GPA-NUM / WS-NES-STUDENT) * 100
MOVE WS-GRAND-NES-STUDENT TO TL-GRAND-NET-GPA-PER
MOVE TOTALS-LINE-4D TO STUDENTS-RECORD-OUT
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINE.
725-PRO-STUDENT-NUM.
EVALUATE MAJOR-IN
WHEN = 'NES'
ADD 1 TO WS-NES-STUDENT
WHEN = 'PGM'
ADD 1 TO WS-PRO-STUDENT
WHEN = 'DIG'
ADD 1 TO WS-DIG-STUDENT
WHEN OTHER
MOVE 0 TO WS-OTHER
END-EVALUATE.
800-PRO-GPA.
EVALUATE MAJOR-IN ALSO STUDENT-GPA-OUT
WHEN = 'NES' ALSO > '3.0'
ADD 1 TO WS-NES-GPA-NUM
WHEN = 'PGM' ALSO > '3.0'
ADD 1 TO WS-PRO-GPA-NUM
WHEN = 'DIG' ALSO > '3.0'
ADD 1 TO WS-DIG-GPA-NUM
WHEN OTHER
MOVE 0 TO WS-OTHER
END-EVALUATE.
You are ANDing your conditions. It seems you want to OR them. Also it seems you have your logic reversed.
I would do it this way...
[...]
FD STUDENTS-FILE-IN.
01 STUDENTS-RECORD-IN.
05 SOCIAL-SECURITY-NUMBER-FIRST-IN PIC X(3).
05 SOCIAL-SECURITY-NUMBER-MIDDLE-IN PIC X(2).
05 SOCIAL-SECURITY-NUMBER-LAST-IN PIC X(4).
05 STUDENT-NAME-FIRST-IN PIC X.
05 STUDENT-NAME-MIDDLE-IN PIC X.
05 STUDENT-NAME-LAST-IN PIC X(9).
05 PIC X(5).
05 GRADUATION-STATUS-IN PIC X.
88 STUDENT-HAS-GRADUATED VALUE 'Y'
05 CLASS-STANDING-IN PIC X.
88 CLASS-STANDING-TO-SKIP VALUES '1' '2'.
05 MAJOR-IN PIC X(3).
88 MAJOR-TO-SKIP VALUES
'DIG' 'NES' 'PGM'.
05 CREDIT-HOURS-EARNED-IN PIC 9(3).
05 CREDIT-POINTS-EARNED-IN PIC 9(3).
[...]
120-CHECK-BYPASS.
IF STUDENT-HAS-GRADUATED
OR CLASS-STANDING-TO-SKIP
OR MAJOR-TO-SKIP
CONTINUE
ELSE
PERFORM 200-PROCESS-ONE-RECORD
END-IF.
This is just freehand, I haven't tried to compile it.

First calculated records in record-line/output-line becomes BLANK in output in COBOL

My calculations are correct. But the output file's ONLY first calculated record becomes as BLANK and affects all the records.
In the output file [A5-SalaryReport-5A.out], you may see the first record's position comes BLANK.
THIS IS MY INPUT FILE [A5.dat]
030ALLDREN RUTH 21G202000002200000
185DONNEMAN THOMAS06G042300900460000
004ACHER WILLIAM 01N072600500720000
325HATFIELD MARK 01G112200201100000
730REEDE OWEN 09G055501000620000
111CARTOLER VIOLET02G099800701000000
590NEIL CLARENCE 07N006500900100000
801SCHEIBER HARRY 01N100000001000000
956WANGLEY THEO 01N099999101000000
999BAKER RON 03G300001403500000
181DELBERT EDWARD 12G065901300770000
311GROLER GRACE 23N064302000770000
318HANEY CAROL 09G500001405500000
487KING MILDRED 18N091996301000000
834TRAWLEY HARRIS 05N732600507700000
027ALHOUER ELAINE 01G257300202500000
171COSTA NAN 15N035600500400000
317HANBEE ALETA 03G500000305500000
739RIDEL ROBERT 05N019400800200000
806STOCKTON NORMAN06G250700704300000
122CENNA DICK 03N577700406000000
207EBERHARDT RON 05G400700904500000
308GLEASON JAMES 01G500000305000000
568LYNNF GERALD 09N448701304500000
909UDSON DORIS 01N449900304500000
100BATES TONY 08N106602001000000
179DAMSON ERIC 03N250201802500000
292EVERLEY DONNA 03G200001702500000
409ICK MICK 25G999999910500000
607ODELLE NICK 10G250701803000000
825TILLMAN DON 12N044401900500000
214EDMONSON RICK 02N100000001000000
310GORMALLY MARIE 03N302200603000000
332HELD ANNA 02G400000204000000
689OWNEY REED 04N317460303500000
802SHEA MICHAEL 06G203300802300000
102BELLSLEY ART 08G300000903500000
282ESTABAN JUAN 19G405500004500000
322HARLETON JEAN 07N089901201000000
505LAMBERT JERRY 01G400100404000000
921ULL GEORGE 18N229885102500000
105BOYLE RALPH 08N804401407800000
215EDSON WILBUR 06G705000808000000
315HALE ALAN 12N400001604500000
THIS IS MY COBOL PROJECT FILE .cbl [A5-SalaryReport-5A.cbl]
identification division.
program-id. A5-SalaryReport-5A.
author. Nirmal Patel.
date-written. 11 March 2021.
* NOTE: I could have finished this, I just had too much for
* this week so I couldn not give this enough time. And I
* started this assignment on the day it it was due, 5th
* March.
environment division.
input-output section.
file-control.
select input-file
assign to "../../../data/A5.dat"
organization is line sequential.
select output-file
assign to "../../../data/A5-SalaryReport-5A.out"
organization is line sequential.
*
select outputdat-file
assign to
"../../../data/A5-SalaryData-NonGrad.dat"
organization is line sequential.
data division.
file section.
fd input-file
data record is input-rec
record contains 36 characters.
01 input-rec.
05 in-emp-no pic 9(3).
05 in-name pic x(15).
05 in-yrs-serv pic 9(2).
05 in-edu-code pic x(1).
88 il-88-type-K value "N".
05 in-prsnt-sly pic 9(5)V99.
05 in-bgt-est pic 9(6)V99.
fd output-file
data record is output-file
record contains 120 characters.
*
01 output-line pic x(120).
fd outputdat-file
data record is outputdat-line
record contains 55 characters.
01 outputdat-line pic x(55).
working-storage section.
01 ws-eof-flag pic x value 'n'.
*
01 ws-heading-info-line.
05 filler pic x(26)
value "Nirmal Patel, Assignment 4".
* ----+----1----+----2----+-
05 filler pic x(15) value spaces.
05 filler pic x(8) value "20210411".
05 filler pic x(23) value spaces.
05 filler pic x(7) value "1951043".
01 ws-heading-line-1.
05 filler pic x(30) value spaces.
05 filler pic x(22)
value "EMPLOYEE SALARY REPORT".
05 filler pic x(14) value spaces.
05 filler pic x(6) value "PAGE ".
05 page-num pic 9 value 1.
01 ws-heading-line-2.
05 filler pic x(3) value "EMP".
05 filler pic x(2) value spaces.
05 filler pic x(3) value "EMP".
05 filler pic x(32) value spaces.
05 filler pic x(7) value "PRESENT".
05 filler pic x(2) value spaces.
05 filler pic x(8) value "INCREASE".
05 filler pic x(5) value spaces.
05 filler pic x(3) value "PAY".
05 filler pic x(11) value spaces.
05 filler pic x(3) value "NEW".
01 ws-heading-line-3.
05 filler pic x(3) value "NUM".
05 filler pic x(2) value spaces.
05 filler pic x(4) value "NAME".
05 filler pic x(10) value spaces.
05 filler pic x(5) value "YEARS".
05 filler pic x(1) value spaces.
05 filler pic x(8) value "POSITION".
05 filler pic x(8) value spaces.
05 filler pic x(6) value "SALARY".
05 filler pic x(5) value spaces.
05 filler pic x(1) value "%".
05 filler pic x(7) value spaces.
05 filler pic x(8) value "INCREASE".
05 filler pic x(7) value spaces.
05 filler pic x(6) value "SALARY".
01 ws-record-line.
05 ws-emp-num pic 9(3).
05 filler pic x(1) value spaces.
05 ws-emp-name pic 9(15).
05 filler pic x(2) value spaces.
05 ws-years pic Z9.
05 filler pic x(2) value spaces.
05 ws-position pic x(12).
05 filler pic x(2) value spaces.
05 ws-salary pic ZZ,ZZ9.99.
05 filler pic x(2) value spaces.
05 ws-inc-per pic 9(2).9.
05 filler pic x(1) value "%".
05 filler pic x(3) value spaces.
05 ws-pay-inc pic $ZZ,ZZ9.99.
05 filler pic x(1) value "+".
05 filler pic x(1) value spaces.
05 filler pic x(1) value "$".
05 filler pic x(1) value spaces.
05 ws-new-salary pic ZZ,ZZZ,ZZ9.99.
01 ws-blank-line.
05 ws-blank-position pic x(12).
01 ws-totals-line-1.
05 filler pic x(15) value "EMPLOYEE CLASS:".
05 filler pic x(8) value spaces.
05 filler pic x(7) value "Analyst".
05 filler pic x(4) value spaces.
05 filler pic x(8) value "Sen Prog".
05 filler pic x(4) value spaces.
05 filler pic x(4) value "Prog".
05 filler pic x(4) value spaces.
05 filler pic x(7) value "Jr Prog".
05 filler pic x(4) value spaces.
05 filler pic x(12) value "Unclassified".
01 ws-totals-line-2.
05 filler pic x(15) value "# ON THIS PAGE:".
05 filler pic x(14) value spaces.
05 ws-no-of-analyst pic 9.
05 filler pic x(11) value spaces.
05 ws-no-of-sen-prog pic 9.
05 filler pic x(7) value spaces.
05 ws-no-of-prog pic 9.
05 filler pic x(10) value spaces.
05 ws-no-of-jr-prog pic 9.
05 filler pic x(15) value spaces.
05 ws-no-of-unclassified
pic 9.
01 ws-sub-total-line-1.
05 filler pic x(18)
value "AVERAGE INCREASES:".
05 filler pic x(3) value spaces.
05 filler pic x(8) value "ANALYST=".
05 filler pic x(5) value spaces.
05 ws-analyst-avg-inc pic Z,ZZ9.99.
05 filler pic x(5) value spaces.
05 filler pic x(9) value "SEN PROG=".
05 filler pic x(3) value spaces.
05 ws-sen-prog-avg-inc pic Z,ZZ9.99.
01 ws-sub-total-line-2.
05 filler pic x(21) value spaces.
05 filler pic x(5) value "PROG=".
05 filler pic x(8) value spaces.
05 ws-prog-avg-inc pic Z,ZZ9.99.
05 filler pic x(5) value spaces.
05 filler pic x(8) value "JR PROG=".
05 filler pic x(4) value spaces.
05 ws-jr-prog-avg-inc pic Z,ZZ9.99.
01 ws-oth-line.
05 filler pic x(25)
value " Type NON-GRADS count = ".
05 ws-oth-staff-count pic zz9.
05 filler pic x(7)
value spaces.
05 filler pic x(26)
value " Type NON-GRADA Salary = ".
05 ws-oth-salary pic $$$,$$$,$$9.
05 filler pic x(38)
value spaces.
05 ws-calc-position pic x(12).
01 ws-const-calc.
05 ws-page-count pic 99 value 0.
05 ws-edu-code pic x(1).
05 ws-o-staff-count pic 999 value 0.
05 ws-o-salary pic 9(10) value 0.
05 ws-s-staff-count pic 999 value 0.
05 ws-s-salary pic 9(10) value 0.
77 ws-lines-per-page pic 99 value 20.
77 ws-line-count pic 99 value 0.
procedure division.
000-main.
open input input-file.
open output output-file
outputdat-file.
write output-line from ws-heading-info-line
*
read input-file
at end
move "y" to ws-eof-flag.
*
* Process each input record and read in next record
*
perform 100-process-pages
until ws-eof-flag equals "y".
write output-line from ws-sub-total-line-1
after advancing 1 line.
write output-line from ws-sub-total-line-2.
close input-file
output-file
outputdat-file.
goback.
100-process-pages.
*
* Initialize detail calculation variables for page
*
move 0 to ws-s-staff-count
ws-s-salary
ws-line-count.
perform 110-print-headings.
*
* process input and output results until
* current page has been filled
* OR EOF has been encountered
*
perform 120-process-lines
varying ws-line-count from 1 by 1
until (ws-line-count > ws-lines-per-page
OR ws-eof-flag = "y").
perform 150-print-page-totals.
*
110-print-headings.
* Increase page count by 1
add 1 to ws-page-count.
move ws-page-count to page-num.
*
* Write the report heading with a blank line before heading
* and blank line after heading
*
if (ws-page-count > 1) then
write output-line
after advancing page
write output-line from ws-heading-line-1
after advancing 1 line
write output-line from ws-heading-line-2
after advancing 2 line
write output-line from ws-heading-line-3
else
write output-line from ws-heading-line-1
after advancing 1 line
write output-line from ws-heading-line-2
after advancing 2 line
write output-line from ws-heading-line-3
end-if.
120-process-lines.
* Decide whether to output to report or data file
*
if il-88-type-K
perform 210-process-data-lines
else
add 1 to ws-line-count
* if ws-line-count = 1
* perform 120-print-headings
* end-if
perform 220-process-rpt-lines
if ws-line-count > ws-lines-per-page
or ws-eof-flag = "y"
perform 230-print-page-totals
end-if
end-if.
*
* Logic to calculate the POSITION based on years of xp..
*
if in-yrs-serv > 15
then
move "ANALYST" to ws-calc-position
else
**
if in-yrs-serv > 7 and in-yrs-serv < 15
then
move "SEN PROG" to ws-calc-position
else
***
if in-yrs-serv > 2 and in-yrs-serv < 7
then
move "PROG" to ws-calc-position
else
****
if in-yrs-serv < 2
then
move "UNCLASSIFIED"
to ws-calc-position
* ----+----1--
end-if
****
end-if
***
end-if
**
end-if
*
* Read next input record for the next iteration of perform loop
*
read input-file
at end
move "y" to ws-eof-flag.
*
*
150-print-page-totals.
*
* PRINT TOTAL LINES
write output-line from ws-totals-line-1
after advancing 2 line.
write output-line from ws-totals-line-2.
*
*
210-process-data-lines.
*
add 1 to ws-o-staff-count.
add in-prsnt-sly to ws-o-salary.
move ws-position to ws-blank-position.
*
write outputdat-line from input-rec.
220-process-rpt-lines.
*
*
* Count staff and accumulate salary for page subtotals
*
add 1 to ws-s-staff-count.
add in-prsnt-sly to ws-s-salary.
*
*
* Output Salesperson Detail Line
*
* Clear the detail line
move spaces to ws-record-line.
*
*
* Move input lines(sales-file) to output lines(report-line)
*
move in-emp-no to ws-emp-num.
move in-name to ws-emp-name.
move in-yrs-serv to ws-years.
move in-prsnt-sly to ws-salary.
move ws-page-count to page-num.
move ws-o-staff-count to ws-oth-staff-count.
move ws-calc-position to ws-position.
*
write output-line from ws-record-line.
230-print-page-totals.
* Move subtotals to subtotal line and write to output file
* with blank line after subtotal line
*
*
write outputdat-line from ws-record-line.
*
*
move 0 to ws-s-staff-count
ws-s-salary.
*
*
end program A5-SalaryReport-5A.
THIS IS MY OUTPUT FILE [A5-SalaryReport-5A.out]
Nirmal Patel, Assignment 4 20210411 1951043
EMPLOYEE SALARY REPORT PAGE 1
EMP EMP PRESENT INCREASE PAY NEW
NUM NAME YEARS POSITION SALARY % INCREASE SALARY
030 ALLDREN RUTH 21 20,200.00
185 DONNEMAN THOMAS 6 ANALYST 4,230.09
325 HATFIELD MARK 1 UNCLASSIFIED 11,220.02
730 REEDE OWEN 9 UNCLASSIFIED 5,550.10
111 CARTOLER VIOLET 2 SEN PROG 9,980.07
999 BAKER RON 3 UNCLASSIFIED 30,000.14
181 DELBERT EDWARD 12 PROG 6,590.13
318 HANEY CAROL 9 ANALYST 50,000.14
EMPLOYEE CLASS: Analyst Sen Prog Prog Jr Prog Unclassified
# ON THIS PAGE:
# ON THIS PAGE:
EMPLOYEE SALARY REPORT PAGE 2
EMP EMP PRESENT INCREASE PAY NEW
NUM NAME YEARS POSITION SALARY % INCREASE SALARY
027 ALHOUER ELAINE 1 PROG 25,730.02
317 HANBEE ALETA 3 UNCLASSIFIED 50,000.03
806 STOCKTON NORMAN 6 PROG 25,070.07
207 EBERHARDT RON 5 PROG 40,070.09
308 GLEASON JAMES 1 PROG 50,000.03
292 EVERLEY DONNA 3 PROG 20,000.17
EMPLOYEE CLASS: Analyst Sen Prog Prog Jr Prog Unclassified
# ON THIS PAGE:
# ON THIS PAGE:
EMPLOYEE SALARY REPORT PAGE 3
EMP EMP PRESENT INCREASE PAY NEW
NUM NAME YEARS POSITION SALARY % INCREASE SALARY
409 ICK MICK 25 PROG 99,999.99
607 ODELLE NICK 10 ANALYST 25,070.18
332 HELD ANNA 2 PROG 40,000.02
802 SHEA MICHAEL 6 PROG 20,330.08
102 BELLSLEY ART 8 PROG 30,000.09
282 ESTABAN JUAN 19 SEN PROG 40,550.00
505 LAMBERT JERRY 1 ANALYST 40,010.04
EMPLOYEE CLASS: Analyst Sen Prog Prog Jr Prog Unclassified
# ON THIS PAGE:
# ON THIS PAGE:
EMPLOYEE SALARY REPORT PAGE 4
EMP EMP PRESENT INCREASE PAY NEW
NUM NAME YEARS POSITION SALARY % INCREASE SALARY
215 EDSON WILBUR 6 SEN PROG 70,500.08
EMPLOYEE CLASS: Analyst Sen Prog Prog Jr Prog Unclassified
# ON THIS PAGE:
AVERAGE INCREASES: ANALYST= SEN PROG=
PROG= JR PROG=
I know it is not an ez thing to figure out and I appreciate whatever answer you provide.
Cheers!
The problem I see is that the correct value for ws-position shows on the next record; this happens because ws-calc-position is determined after the line is printed. This caused a blank on the first record and an incorrect value on the following print lines.
I suggest moving the code for determining ws-calc-position to just before it is needed. 120-process-lines and 220-process-rpt-lines incorporates those suggestions.
The IF code should not include AND, as expressed originally. It causes some values to be missed, where in-yrs-serv is 15, 07, or 02. Those particular values caused (or would cause) the previously determined position to appear in the output. That change has be made below.
Also, this line
05 ws-emp-name pic 9(15).
should be
05 ws-emp-name pic x(15).
120-process-lines.
* Decide whether to output to report or data file
*
if il-88-type-K
perform 210-process-data-lines
else
add 1 to ws-line-count
* if ws-line-count = 1
* perform 120-print-headings
* end-if
perform 220-process-rpt-lines
if ws-line-count > ws-lines-per-page
or ws-eof-flag = "y"
perform 230-print-page-totals
end-if
end-if.
* NOTE: Moved code to determine position to 225-determine-position
*
* Read next input record for the next iteration of perform loop
*
read input-file
at end
move "y" to ws-eof-flag.
220-process-rpt-lines.
*
*
* Count staff and accumulate salary for page subtotals
*
add 1 to ws-s-staff-count.
add in-prsnt-sly to ws-s-salary.
*
*
* Output Salesperson Detail Line
*
* Clear the detail line
move spaces to ws-record-line.
*
*
* Move input lines(sales-file) to output lines(report-line)
*
move in-emp-no to ws-emp-num.
move in-name to ws-emp-name.
move in-yrs-serv to ws-years.
move in-prsnt-sly to ws-salary.
move ws-page-count to page-num.
move ws-o-staff-count to ws-oth-staff-count.
perform 225-determine-position.
move ws-calc-position to ws-position.
*
write output-line from ws-record-line.
225-determine-position.
*
* Logic to calculate the POSITION based on years of xp..
*
if in-yrs-serv > 15
then
move "ANALYST" to ws-calc-position
else
**
if in-yrs-serv > 7
then
move "SEN PROG" to ws-calc-position
else
***
if in-yrs-serv > 2
then
move "PROG" to ws-calc-position
else
****
move "UNCLASSIFIED" to ws-calc-position
****
end-if
***
end-if
**
end-if.

IGZ0201W and IGZ0035S errors in COBOL

*-----------------------
IDENTIFICATION DIVISION.
*-----------------------
PROGRAM-ID. TOPACCTS
AUTHOR. Sohan Kundu.
*--------------------
ENVIRONMENT DIVISION.
*--------------------
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PRINT-LINE ASSIGN TO PRTLINE.
SELECT ACCT-REC ASSIGN TO ACCTREC.
*-------------
DATA DIVISION.
*-------------
FILE SECTION.
FD PRINT-LINE RECORD CONTAINS 80 CHARACTERS RECORDING MODE F.
01 PRINT-REC.
05 FILLER PIC X(01) VALUE SPACES.
05 FIRST-NAME-O PIC X(11).
05 FILLER PIC X(02) VALUE SPACES.
05 LAST-NAME-O PIC X(22).
05 FILLER PIC X(02) VALUE SPACES.
05 ACCT-BALANCE-O PIC X(12).
05 FILLER PIC X(30) VALUE SPACES.
*
FD ACCT-REC RECORD CONTAINS 80 CHARACTERS RECORDING MODE F.
01 ACCT-FIELDS.
05 FIRST-NAME PIC X(11).
05 LAST-NAME PIC X(22).
05 FILLER PIC X(28).
05 ACCT-BALANCE PIC X(12).
05 FILLER PIC X(7).
*
WORKING-STORAGE SECTION.
01 FLAGS.
05 LASTREC PIC X VALUE SPACE.
*
01 TOTAL-CLIENTS.
05 FILLER PIC X(14) VALUE
'# OF RECORDS: '.
05 CLIENTS PIC 9(3) VALUE ZERO.
05 FILLER PIC X(63) VALUE SPACES.
*
01 HEADER-1.
05 FILLER PIC X(30) VALUE 'REPORT FOR TOP ACCOUNT HOLDERS'.
05 FILLER PIC X(50) VALUE SPACES.
*
01 HEADER-2.
05 FILLER PIC X(05) VALUE 'Year '.
05 HDR-YR PIC 9(04).
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(06) VALUE 'Month '.
05 HDR-MO PIC X(02).
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(04) VALUE 'Day '.
05 HDR-DAY PIC X(02).
05 FILLER PIC X(53) VALUE SPACES.
*
01 HEADER-3.
05 FILLER PIC X(11) VALUE 'First Name '.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(10) VALUE 'Last Name '.
05 FILLER PIC X(14) VALUE SPACES.
05 FILLER PIC X(08) VALUE 'Balance '.
05 FILLER PIC X(35) VALUE SPACES.
*
01 HEADER-4.
05 FILLER PIC X(11) VALUE '-----------'.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(10) VALUE '----------'.
05 FILLER PIC X(14) VALUE SPACES.
05 FILLER PIC X(08) VALUE '--------'.
05 FILLER PIC X(35) VALUE SPACES.
*
01 WS-CURRENT-DATE-DATA.
05 WS-CURRENT-DATE.
10 WS-CURRENT-YEAR PIC 9(04).
10 WS-CURRENT-MONTH PIC 9(02).
10 WS-CURRENT-DAY PIC 9(02).
05 WS-CURRENT-TIME.
10 WS-CURRENT-HOURS PIC 9(02).
10 WS-CURRENT-MINUTE PIC 9(02).
10 WS-CURRENT-SECOND PIC 9(02).
10 WS-CURRENT-MILLISECONDS PIC 9(02).
*
*------------------
PROCEDURE DIVISION.
*------------------
OPEN-FILES.
OPEN INPUT ACCT-REC.
OPEN OUTPUT PRINT-LINE.
*
WRITE-HEADERS.
MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-DATA.
MOVE WS-CURRENT-YEAR TO HDR-YR.
MOVE WS-CURRENT-MONTH TO HDR-MO.
MOVE WS-CURRENT-DAY TO HDR-DAY.
WRITE PRINT-REC FROM HEADER-1.
WRITE PRINT-REC FROM HEADER-2.
MOVE SPACES TO PRINT-REC.
WRITE PRINT-REC AFTER ADVANCING 1 LINES.
WRITE PRINT-REC FROM HEADER-3.
WRITE PRINT-REC FROM HEADER-4.
MOVE SPACES TO PRINT-REC.
*
READ-NEXT-RECORD.
PERFORM READ-RECORD
PERFORM UNTIL LASTREC = 'Y'
PERFORM IS-BALANCE-HIGH
PERFORM READ-RECORD
END-PERFORM
.
*
CLOSE-STOP.
WRITE PRINT-REC FROM TOTAL-CLIENTS.
CLOSE ACCT-REC.
CLOSE PRINT-LINE.
STOP RUN.
*
READ-RECORD.
READ ACCT-REC
AT END MOVE 'Y' TO LASTREC
END-READ.
*
IS-BALANCE-HIGH.
IF FUNCTION NUMVAL-C(ACCT-BALANCE) > 8500000 THEN
ADD 1 TO CLIENTS
PERFORM WRITE-RECORD
END-IF.
*
WRITE-RECORD.
MOVE FIRST-NAME TO FIRST-NAME-O.
MOVE LAST-NAME TO LAST-NAME-O.
MOVE ACCT-BALANCE TO ACCT-BALANCE-O.
WRITE PRINT-REC.
*
I want to read the account details from an input file and print if the balance is more than 8500000.
The code is showing the following error:
IGZ0201W A file attribute mismatch was detected. File PRINT-LINE in program TOPACCTS had a record length of 81 and
the file specified in the ASSIGN clause had a record length of 80.
IGZ0035S There was an unsuccessful OPEN or CLOSE of file PRTLINE in program TOPACCTS at relative location X'1E8'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 39.
From compile unit TOPACCTS at entry point TOPACCTS at compile unit offset +000001E8 at entry offset +000001E8
at address 1B8001E8.
In the JCL that you are using to execute this program (as a batchjob), within the step with EXEC PGM=TOPACCTS, make sure that you use a DD-card for your output file PRTLINE which looks similar to this:
//PRTLINE DD DISP=(NEW,CATLG),DSN=YOUR.DSN.GOES.HERE,
// UNIT=SYSDA,SPACE=(CYL,(5,5)),
// RECFM=FB,LRECL=80
That way you'll avoid the status code '39', which indicates that there is a mismatch between your record length of 80 (as shown in your program with CONTAINS 80 CHARACTERS), and whatever you specified in your JCL's DD-card.

COBOL code wont compile and create an executable

I'm trying to create a report for a given input file where I am supposed to ill examine each record to determine if it fails to meet certain criteria. The issue that I am facing now is that the cob file wont compile eventhough it doesn't explicitly show any errors when compiling it on the command window and the executable doesn't get created. I was wondering if any of you could help me figure out where the error lies in my code.
Identification Division.
Program-ID. lab5.
Environment Division.
Input-Output Section.
File-Control.
Select PayrollFile
Assign to "lab5-in.dat"
Organization is Line Sequential.
Select OutputReport
Assign to "lab5-out.dat"
Organization is Line Sequential.
Data Division.
File Section.
FD PayrollFile.
01 Input-Rec.
05 Rec-RegionNum Pic X(2).
05 Rec-RegionName Pic X(15).
05 Rec-DeptNum Pic X(5).
05 Rec-DeptName Pic X(30).
05 Rec-EmployeeNum Pic X(5).
05 Rec-LastName Pic X(20).
05 Rec-FirstName Pic X(15).
05 Rec-Gender Pic X.
05 Rec-Address Pic X(20).
05 Rec-CityState Pic X(20).
05 Rec-Title Pic X(20).
05 Rec-DOB Pic 9(8).
05 Rec-DOH.
10 RecDOH-YYYY Pic 9(4).
10 RecDOH-MM Pic 9(2).
10 RecDOH-DD Pic 9(2).
05 Rec-Marital Pic X.
05 Rec-Deps Pic 99.
05 Rec-SD Pic X(3).
05 Rec-Ins Pic X(3).
05 Rec-401k Pic V999.
05 Rec-PayCode Pic X.
05 Rec-Pay Pic 9(7)V9(2).
05 Rec-HrsPerWeek Pic 9(2)V9(2).
05 Rec-CommissionRate Pic V999.
05 Rec-ActualSales Pic 9(7)V9(2).
FD OutputReport.
01 Output-Rec Pic X(210).
Working-Storage Section.
01 WS-EmployeeNum Pic X(5).
01 WS-DeptName Pic X(30).
01 WS-Gender Pic X.
88 ValidGender Values "M" "m" "F" "f".
01 WS-Marital Pic X.
88 ValidMarital Values "D" "d" "M" "m" "P" "p" "S" "s" "W"
"w".
01 WS-PayCode Pic X.
88 ValidPayCode Values "C" "c" "H" "h" "S" "s".
01 WS-HrsPerWeek Pic S9(2)V9(2).
01 WS-Pay Pic S9(7)V9(2).
01 WS-DOH.
10 DOH-YYYY Pic 9(4).
10 DOH-MM Pic 9(2).
10 DOH-DD Pic 9(2).
01 WS-SD Pic X(3).
01 WS-Date.
05 WS-YYYY Pic 9(4).
05 WS-MM Pic 9(2).
05 WS-DD Pic 9(2).
01 EndOfFileIndicator Pic X.
88 EOF Value "Y" When Set To False is "N".
01 Total-Line.
05 Pic X(25) Value "Total errors: ".
05 TL-TotalE Pic ZZ9.
01 TotalRE-Line.
05 Pic X(50) Value "Total record with errors: ".
05 TL-TotalRE Pic ZZ9.
01 TotError Pic 9(3).
01 TotRecordError Pic 9(3).
01 CurrentRec Pic X(208).
01 Blank-Line Pic X Value Spaces.
01 Report-Fields.
05 PageNumber Pic 99 Value 0.
05 LinesPerPage Pic 99 Value 35.
05 LineNumber Pic 99 Value 99.
Procedure Division.
000-MAIN.
Perform 100-initialize
Perform until EOF
Read PayrollFile
At End
Set EOF to True
not at end
perform 300-process
End-read
End-perform
Perform 900-finalize
Close PayrollFile OutputReport
Stop Run.
100-initialize.
Perform 110-open-files
Move Zero to TotError
Move Zero to TotRecordError.
110-open-files.
Open Input PayrollFile
Open Output OutputReport.
300-Process.
Move Input-Rec to CurrentRec
Move Rec-EmployeeNum to WS-EmployeeNum
Move Rec-DeptName to WS-DeptName
Move Rec-Gender to WS-Gender
Move Rec-Marital to WS-Marital
Move Rec-PayCode to WS-PayCode
Move Rec-HrsPerWeek to WS-HrsPerWeek
Move Rec-Pay to WS-Pay
Move Rec-DOH to WS-DOH
Perform 400-check.
400-check.
If WS-EmployeeNum is Not Numeric
Add 1 to TotError TotRecordError
End-If
If WS-DeptName Is Not Alphabetic
Add 1 to TotError TotRecordError
End-If
If Not ValidGender
Add 1 to TotError TotRecordError
End-If
If Not ValidMarital
Add 1 to TotError TotRecordError
End-If
If Not ValidPayCode
Add 1 to TotError TotRecordError
End-If
If WS-HrsPerWeek Is Negative And >= 60
Add 2 to TotError
Add 1 to TotRecordError
End-If
If WS-HrsPerWeek Is Negative Or >=60
Add 1 to TotError TotRecordError
End-If
If WS-Pay Is Not Numeric and Is Negative
Add 2 to TotError
Add 1 to TotRecordError
End-If
If WS-Pay Is Negative Or Not Numeric
Add 1 to TotError TotRecordError
End-If
If Function Test-Date-YYYYMMDD(WS-DOH) Is Not Zero Or WS-DOH Is Not Numeric
Add 1 to TotError TotRecordError
End-If.
900-finalize.
perform 950-print-grand-total.
950-print-grand-total.
Write Output-Rec from Blank-Line
After advancing 1 line
Move TotError to TL-TotalE
Write Output-Rec from Total-Line
after advancing 1 line
Move TotRecordError to TL-TotalRE
Write Output-Rec from TotalRE-Line
after advancing 1 line.
As you've used the GnuCOBOL tag I've just used a simple compile.
Result:
main.cobc: in paragraph '400-check':
main.cobc: 139: error: invalid expression
main.cobc: 143: error: invalid expression
main.cobc: 146: error: invalid expression
main.cobc: 150: error: invalid expression
main.cobc: 153: error: FUNCTION 'TEST-DATE-YYYYMMDD' has invalid parameter
main.cobc: 153: error: invalid expression
main.cobc: 153: error: invalid expression
The invalid expression part is "is negative" (additional line 139 doesn't make sense "Negative And >= 60" as this would never be true; line 146 is even more weird: "Is Not Numeric and Is Negative").
The issue that I am facing now is that the cob file wont compile eventhough it doesn't explicitly show any errors when compiling it
I guess the messages from the compilers are redirected somewhere.

Invalid type cast from 'null'

I am still new to COBOL and have been working on a project for school for almost a week now. I am running OpenCobol 1.1.
When I try to compile it I get this error.
typeck.c:5912: Invalid type cast from 'null'
Tag 1 0 Tag 2 10
Aborting compile of lab4.cob at line 214
I've been frustrated because I've tried changing the code around a lot with no luck.
Procedure Division.
000-Main.
Perform 100-initialize
Perform Until EndOfFile = "Y"
Read Lab4-in-File
At End
Move "Y" To EndOfFile
Not At End
Perform 300-process
End-Read
End-Perform
Perform 900-finalize
Stop Run.
100-intialize.
Perform 110-open-files
Perform 120-get-data.
110-open-files.
Open Input Lab4-in-File
Output Ot-File.
120-get-date.
Accept WS-date from date yyyymmdd
Move WS-Year To PH-Year
Move WS-Month To PH-Month
Move WS-Day To PH-Day.
300-process.
Move Dept-no To dl-dep-no
Move Employee-no To dl-emp-no
If First-name Not = "Null"
String First-name Delimited By Size
" " Delimited By Size
Last-name Delimited By Size
Into dl-emp
else
Move Last-name To dl-emp
End-If
Move Job-title To dl-job
Move DOH To dl-doh
Move Mar-status To dl-marital
Move Dependents To dl-dependents
Move MCoverage To dl-insurance
Move DCoverage To dl-insurance
Move VCoverage To dl-insurance
Move 401K To dl-401k
Move Pay-code To dl-pay-code
If Pay-code = "C" Or "S"
Compute Pay-hold rounded =
Pay / 12
Move Pay-hold To dl-monthly-pay
else
Compute Pay-hold rounded =
Pay * HPW * 4
Move Pay-hold To dl-monthly-pay
End-If
If Pay-code = "C"
Compute Com-hold rounded =
Act-sale * C-rate
Move Com-hold To dl-commission
Else
Move 0 To dl-commission
End-If
Perform 800-print
Multiply C-rate By Act-sale Giving
total-sales
Add Pay To total-sales.
800-print.
If LineNum > LinesPerPage
Perform 825-new-page
End-If
Write Lab4-Record2 From Detail-Line
**After advancing 1 line** *> This is line 214
Add 1 To LineNum.
825-new-page.
If PageNum > 0
Write Lab4-Record2 From Blank-line
After advancing 1 line
End-If
Add 1 To PageNum
Move PageNum To PH-PageNo
Write Lab4-Record2 From Page-Header
After advancing page
Write Lab4-Record2 From Blank-line
After advancing 1 line
Write Lab4-Record2 From Column-Header
After advancing 1 line
Write Lab4-Record2 From Blank-line
After advancing 1 line
Move 5 To LineNum.
900-finalize.
Perform 950-print-monthly-total
Perform 999-close-files.
950-print-monthly-total.
If LineNum + 1 > LinesPerPage
Perform 825-new-page
End-If
Write Lab4-Record2 From Blank-line
After advancing 1 line
Move total-sales To Total-pay
Write Lab4-Record2 From Total-Line
After advancing 1 line
Add 2 To LineNum.
999-close-files.
Close Lab4-in-File Ot-File.
I would really appreciate it if someone could help me find what is causing the error. Thanks in advance!
Working-Storage Section.
01 EndOfFile Pic X Value "N".
01 Report-fields.
05 PageNum Pic 9(3) value 0.
05 LinesPerPage Pic 9(2) value 40.
05 LineNum Pic 9(2) value 41.
01 WS-date.
05 WS-Year Pic 9(4).
05 WS-Month Pic 99.
05 WS-Day Pic 99.
01 total-fields.
05 total-sales Pic 9(11)v99 Value 0.
01 Page-Header.
05 PH-Month Pic Z9/.
05 PH-Day Pic 99/.
05 PH-Year Pic 9999.
05 Pic X(7) Value Spaces.
05 Pic X(29) Value "Stomper &" &
" Wombat's Emporium"
05 Pic X(6) Value "Page:".
05 PH-PageNo Pic ZZ9.
01 Column-Header.
05 Pic X(8) Value "Dep #".
05 Pic X(15) Value "Emp #".
05 Pic X(27) Value "Employee".
05 Pic X(18) Value "Title".
05 Pic X(9) Value "DOH".
05 Pic X(9) Value "Marital".
05 Pic X(7) Value "#Deps".
05 Pic X(6) Value "Ins".
05 Pic X(6) Value "401K".
05 Pic X(6) Value "Pay".
05 Pic X(27) Value "Expected " &
"Pay + Commission".
01 Pay-hold Pic 9(9)V9(2) Value 0.
01 Com-hold Pic 9(9)V9(2) Value 0.
01 Detail-Line.
05 dl-dep-no Pic X(5).
05 Pic X(1) Value spaces.
05 dl-emp-no Pic X(5).
05 Pic X(1) Value spaces.
05 dl-emp Pic X(35).
05 Pic X(1) Value spaces.
05 dl-job Pic X(20).
05 Pic X(1) Value spaces.
05 dl-doh Pic X(8).
05 Pic X(1) Value spaces.
05 dl-marital Pic X.
05 Pic X(1) Value spaces.
05 dl-dependents Pic 9(2).
05 Pic X(1) Value spaces.
05 dl-insurance Pic X(3).
05 Pic X(1) Value spaces.
05 dl-401k Pic Z.9ZZ.
05 Pic X(1) Value spaces.
05 dl-pay-code Pic X.
05 Pic X(1) Value spaces.
05 dl-monthly-pay Pic $$$$,$$$,$$9.99.
05 Pic X(1) Value spaces.
05 dl-commission Pic $$$,$$9.99.
01 Total-Line.
05 Pic X(61) Value Spaces.
05 Pic X(24) Value "Total" &
" Expected Payroll: ".
05 Total-pay Pic $$$$,$$$,$$$,$$9.99.
01 Blank-line Pic X Value spaces.
The compiler has a broken parser. It is broken because of a coding error (still a compiler bug). In cases like this you only have the chance to either spot the error or - much better - use a newer version.
I've just put your code in an online compiler using the last release of the compiler: GnuCOBOL 2.2. I highly suggest to upgrade to at least this version.
See your code here - I've just added a minimal header and end.
Then click on "Execute" and you compile it online, leading to the following error messages:
main.cobc: 27: error: duplicate PICTURE clause
main.cobc: 27: error: duplicate VALUE clause
main.cobc: 64: error: a Z or * which is after the decimal point cannot follow 9
If you check the line 27 in this program you see
05 Pic X(29) Value "Stomper &" &
" Wombat's Emporium" *> <<- missing period
05 Pic X(6) Value "Page:".
Fixed code is also available.

Resources