Reputation: 143
I am new to Cobol and I am not so sure about the syntax. This error pop out when I try to compile my code but I do not know What is wrong with my code.
IDENTIFICATION DIVISION.
PROGRAM-ID. atd.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT m-attendance ASSIGN TO 'monthy-attendance.txt'
ORGANIZATION IS LINE SEQUENTIAL.
FILE STATUS IS mFS.
SELECT d-attendance ASSIGN TO 'attendance.txt'
ORGANIZATION IS LINE SEQUENTIAL.
FILE STATUS IS dFS.
SELECT employees ASSIGN TO 'employees.txt'
ORGANIZATION IS LINE SEQUENTIAL.
FILE STATUS IS eFS.
SELECT summary ASSIGN TO 'summary.txt'
ORGANIZATION IS LINE SEQUENTIAL.
FILE STATUS IS sFS.
DATA DIVISION.
FILE SECTION.
FD d-attendance.
* 01 d-attendance-FILE.
* 05 Date1 PIC X(10).
05 ATD-RECORD.
10 PID PIC 9(4).
10 Sta PIC A(6).
10 Tim PIC X(16).
FD m-attendance.
* 01 m-attendance-FILE.
* 05 Date1 PIC X(7).
05 PID-ATD-RECORD.
10 PID PIC 9(4).
10 ABS PIC 9(3).
10 C15 PIC 9(3).
10 COT PIC 9(3).
FD employees.
* 01 employees-FILE.
05 PID-RECORD.
10 PID PIC 9(4).
10 SUR PIC A(10).
10 NAM PIC A(20).
10 SEX PIC A.
10 BIR PIC X(10).
10 EMD PIC X(10).
10 DEP PIC A(3).
10 SAL PIC 9(6).
FD summary.
* 01 summary-FILE.
* 05 DATE1 PIC X(18).
05 PID-SUM-RECORD.
10 PID PIC 9(4).
10 SUR PIC A(10).
10 NAM PIC A(20).
10 DEP PIC A(3).
10 STA PIC A(6).
WORKING-STORAGE SECTION.
01 FS PIC 99.
01 PCOUNT PIC 9(4).
01 ACOUNT PIC 9(4).
01 LCOUNT PIC 9(4).
01 SCOUNT PIC 9(4).
PROCEDURE DIVISION.
001-MAIN.
OPEN INPUT d-attendance.
perform 002-READ.
CLOSE d-attendance.
DISPLAY 'Hello, world'.
STOP RUN.
002-READ.
READ d-attendance
IF dfs = 00
GOTO 002-READ
END-IF.
IF dfs != 00
STOP RUN.
END-IF.
STOP RUN.
sorry It is quite long but I have learned only c before, I am not so sure about if the indentation is correct either so I put all my code up here. Is this the correct way to open and read a file?
Upvotes: 2
Views: 1146
Reputation: 4407
Remove the separator periods after LINE SEQUENTIAL
.
Remove the comment indicators (the *
) in column 7.
In WORKING-STORAGE
, remove the line with FS
. Add the following lines.
01 mFS PIC XX.
01 dFS PIC XX.
01 eFS PIC XX.
01 sFS PIC XX.
Change IF dfs = 00
to IF dfs = "00"
.
Change IF dfs != 00
to IF dfs not = "00"
.
And, after the immediately following STOP RUN
, remove the separator period.
Remove the last STOP RUN
.
These changes should eliminate all the syntax errors and remove unnecessary code. But will not change the logic flow to do what you seem to want.
To do want you seem to want. Remove this code:
IF dfs != 00
STOP RUN. *> recommended changes not shown
END-IF.
This will allow 002-READ
to return to 001-MAIN
to continue processing with the CLOSE
statement.
Upvotes: 4