-
Notifications
You must be signed in to change notification settings - Fork 0
/
COURSE-MASTER.cbl
106 lines (103 loc) · 4.39 KB
/
COURSE-MASTER.cbl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
IDENTIFICATION DIVISION.
PROGRAM-ID. COURSE-MASTER.
*-----------------------------------------------------------------
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO
'../FILES/COURSE-MASTER-S.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT SORT-WORK ASSIGN TO 'SORTWORK.TXT'.
SELECT OUT-FILE ASSIGN TO
'../FILES/COURSE-MASTER-SORT.DAT'
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD KEY IS O-COURSE-ID
FILE STATUS IS WS-STAT.
*-----------------------------------------------------------------
DATA DIVISION.
*-----------------------------------------------------------------
FILE SECTION.
FD IN-FILE.
01 IN-REC.
03 COURSE-ID PIC X(9).
03 FILLER PIC XX VALUE SPACES.
03 COURSE-NAME PIC X(35).
03 FILLER PIC X VALUE SPACE.
03 COURSE-CREDIT PIC X(4).
03 FILLER PIC XX VALUE SPACES.
03 COURSE-STAT PIC X.
SD SORT-WORK.
01 SORT-REC.
03 S-COURSE-ID PIC X(9).
03 S-COURSE-NAME PIC X(35).
03 S-COURSE-CREDIT PIC X(4).
03 S-COURSE-STAT PIC X.
FD OUT-FILE.
01 OUT-REC.
03 O-COURSE-ID PIC X(9).
03 O-COURSE-NAME PIC X(35).
03 O-COURSE-CREDIT PIC X(4).
03 O-COURSE-STAT PIC X.
WORKING-STORAGE SECTION.
01 MISC-VARS.
03 WS-RESP PIC X VALUE SPACE.
03 WS-STAT PIC 99.
03 WS-EOF PIC X VALUE 'N'.
88 EOF VALUE 'Y'.
01 WS-DTL-LN.
03 WS-COURSE-ID PIC X(9).
03 FILLER PIC XX.
03 WS-COURSE-NAME PIC X(35).
03 FILLER PIC XX.
03 WS-COURSE-CREDIT PIC X(4).
03 FILLER PIC XX.
03 WS-COURSE-STAT PIC X.
SCREEN SECTION.
01 BLNK-SCRN.
03 BLANK SCREEN.
*-----------------------------------------------------------------
PROCEDURE DIVISION.
000-MAIN.
OPEN INPUT IN-FILE.
OPEN OUTPUT OUT-FILE.
SORT SORT-WORK
ON ASCENDING KEY S-COURSE-ID
INPUT PROCEDURE 100-FILE-IN
OUTPUT PROCEDURE 200-FILE-OUT.
DISPLAY BLNK-SCRN.
DISPLAY 'BUILD SUCCESSFULLY'.
DISPLAY 'PRESS ENTER TO RETURN TO COURSE MENU'.
ACCEPT WS-RESP.
CLOSE IN-FILE.
CLOSE OUT-FILE.
EXIT PROGRAM.
*-----------------------------------------------------------------
100-FILE-IN.
PERFORM UNTIL EOF
READ IN-FILE
AT END
MOVE 'Y' TO WS-EOF
NOT AT END
MOVE COURSE-ID TO S-COURSE-ID
MOVE COURSE-NAME TO S-COURSE-NAME
MOVE COURSE-CREDIT TO S-COURSE-CREDIT
MOVE COURSE-STAT TO S-COURSE-STAT
RELEASE SORT-REC
END-READ
END-PERFORM.
*-----------------------------------------------------------------
200-FILE-OUT.
MOVE 'N' TO WS-EOF.
PERFORM UNTIL EOF
RETURN SORT-WORK
AT END
MOVE 'Y' TO WS-EOF
NOT AT END
MOVE S-COURSE-ID TO O-COURSE-ID
MOVE S-COURSE-NAME TO O-COURSE-NAME
MOVE S-COURSE-CREDIT TO O-COURSE-CREDIT
MOVE S-COURSE-STAT TO O-COURSE-STAT
WRITE OUT-REC
END-RETURN
END-PERFORM.