-
Notifications
You must be signed in to change notification settings - Fork 37
/
FILEREAD
54 lines (54 loc) · 1.76 KB
/
FILEREAD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
********************************************
* COBOL PROGRAM USING FILES *
* INPUT IS FB PS FILE - EMPDD *
* OUTPUT IS TO DISPLAY *
* SEQUENTIAL FILE *
* PERFORMING READ OPERATION *
* DATE : 07.08.2020 *
* AUTHOR : VIJAY KUMAR *
********************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. FILES.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPFILE ASSIGN TO EMPDD
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS WS-STAT.
DATA DIVISION.
FILE SECTION.
FD EMPFILE
RECORDING MODE IS F
RECORD CONTAINS 36 CHARACTERS.
01 EMPREC.
05 EMP-ID PIC X(5).
05 FILLER PIC X(2).
05 EMP-NAME PIC X(10).
05 FILLER PIC X(2).
05 EMP-LOC PIC X(10).
05 FILLER PIC X(2).
05 EMP-SAL PIC 9(5).
WORKING-STORAGE SECTION.
77 ARE-THERE-ANY-RECORDS PIC X VALUE 'Y'.
88 NO-MORE-RECORDS VALUE 'N'.
77 WS-STAT PIC X(2) VALUE SPACE.
PROCEDURE DIVISION.
MAIN-PARA.
PERFORM OPEN-PARA.
PERFORM PROCESS-PARA UNTIL NO-MORE-RECORDS.
PERFORM CLOSE-PARA.
STOP RUN.
OPEN-PARA.
OPEN INPUT EMPFILE.
PROCESS-PARA.
READ EMPFILE
AT END
DISPLAY WS-STAT
MOVE 'N' TO ARE-THERE-ANY-RECORDS
NOT AT END
DISPLAY EMPREC
DISPLAY WS-STAT
END-READ.
CLOSE-PARA.
CLOSE EMPFILE.