Skip to content

Commit e62a03d

Browse files
committed
New CBL0003.cobol program for chapter "Program Structure",
based on CBL0001.cobol and HELLO.cobol. Old CBL0003J.jcl copied to CBL0033J.jcl and CBL0003J.jcl changed to include compilation and link of HELLO.cobol Signed-off-by: klausmelcher <[email protected]>
1 parent e897fd5 commit e62a03d

File tree

3 files changed

+159
-4
lines changed

3 files changed

+159
-4
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
*-----------------------
2+
IDENTIFICATION DIVISION.
3+
*-----------------------
4+
PROGRAM-ID. CBL0003
5+
AUTHOR. Otto B. Fun.
6+
*--------------------
7+
ENVIRONMENT DIVISION.
8+
*--------------------
9+
INPUT-OUTPUT SECTION.
10+
FILE-CONTROL.
11+
SELECT PRINT-LINE ASSIGN TO PRTLINE.
12+
SELECT ACCT-REC ASSIGN TO ACCTREC.
13+
*-------------
14+
DATA DIVISION.
15+
*-------------
16+
FILE SECTION.
17+
FD PRINT-LINE RECORDING MODE F.
18+
01 PRINT-REC.
19+
05 ACCT-NO-O PIC X(8).
20+
05 ACCT-LIMIT-O PIC $$,$$$,$$9.99.
21+
05 ACCT-BALANCE-O PIC $$,$$$,$$9.99.
22+
05 LAST-NAME-O PIC X(20).
23+
05 FIRST-NAME-O PIC X(15).
24+
05 COMMENTS-O PIC X(50).
25+
*
26+
FD ACCT-REC RECORDING MODE F.
27+
01 ACCT-FIELDS.
28+
05 ACCT-NO PIC X(8).
29+
05 ACCT-LIMIT PIC S9(7)V99 COMP-3.
30+
05 ACCT-BALANCE PIC S9(7)V99 COMP-3.
31+
05 LAST-NAME PIC X(20).
32+
05 FIRST-NAME PIC X(15).
33+
05 CLIENT-ADDR.
34+
10 STREET-ADDR PIC X(25).
35+
10 CITY-COUNTY PIC X(20).
36+
10 USA-STATE PIC X(15).
37+
05 RESERVED PIC X(7).
38+
05 COMMENTS PIC X(50).
39+
*
40+
WORKING-STORAGE SECTION.
41+
01 FLAGS.
42+
05 LASTREC PIC X VALUE SPACE.
43+
01 COUNTER PIC 9(2) VALUE 0.
44+
*COUNTER is used for the PERFORM VARYING statement
45+
*------------------
46+
PROCEDURE DIVISION.
47+
*------------------
48+
1000-OPEN-FILES.
49+
OPEN INPUT ACCT-REC.
50+
OPEN OUTPUT PRINT-LINE.
51+
1000-OPEN-FILES-END.
52+
*The prefix "1000" is increased thoughout the code and
53+
*is used as a programming technique to better locate
54+
*referenced paragraphs in a sentence.
55+
*The paragraph suffixed with "-END" is an empty one
56+
*that serves as a visual delimiter for ending a paragraph
57+
*similiar to a "}" in other programming languages
58+
*
59+
2000-READ-FIRST-RECORD.
60+
PERFORM 4000-READ-RECORD.
61+
PERFORM 5000-WRITE-RECORD.
62+
GO TO 2100-READ-TEN-RECORDS.
63+
*GO TO passes control to another section of the code, but
64+
*unlike the PERFORM keyword, it will not return control
65+
*to the next line in the code
66+
2000-READ-FIRST-RECORD-END.
67+
*
68+
DISPLAY ' THIS IS THE FIRST RECORD '.
69+
*notice that because of GO TO, this command will
70+
*never be executed
71+
*
72+
2100-READ-TEN-RECORDS.
73+
PERFORM 10 TIMES
74+
PERFORM 4000-READ-RECORD
75+
PERFORM 5000-WRITE-RECORD
76+
END-PERFORM.
77+
2100-READ-TEN-RECORDS-END.
78+
*TIMES repeats a perform statement, it's number can be
79+
*either set or given by a variable
80+
*
81+
2200-READ-ANOTHER-RECORD.
82+
PERFORM 4000-READ-RECORD THRU 5000-WRITE-RECORD.
83+
2200-READ-ANOTHER-RECORD-END.
84+
*THRU or THROUGH list the start and end of which
85+
*paragraphs will be executed in a sequential order
86+
*
87+
2300-READ-NEXT-RECORDS.
88+
PERFORM VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER
89+
EQUAL 34
90+
PERFORM 4000-READ-RECORD THRU 5000-WRITE-RECORD
91+
END-PERFORM.
92+
2300-READ-NEXT-RECORDS-END.
93+
*Loop printing the remaining 34 records by varying the
94+
*variable COUNTER after each iteration.
95+
*The sentence PERFORM VARYING is continued on the next
96+
*line by starting on the B Area (column 12)
97+
*
98+
2400-CALLING-SUBPROGRAM.
99+
CALL 'HELLO'.
100+
2400-CALLING-SUBPROGRAM-END.
101+
*The program HELLO from the first Lab is called as a
102+
*subprogram from CBL0003. The JCL that compiles CBL0003
103+
*also compiles HELLO and links them together.
104+
*
105+
3000-CLOSE-STOP.
106+
CLOSE ACCT-REC.
107+
CLOSE PRINT-LINE.
108+
STOP RUN.
109+
*Without STOP RUN here, the next paragraphs would
110+
*execute once more
111+
3000-CLOSE-STOP-END.
112+
*
113+
4000-READ-RECORD.
114+
READ ACCT-REC
115+
AT END MOVE 'Y' TO LASTREC
116+
END-READ.
117+
4000-READ-RECORD-END.
118+
*
119+
5000-WRITE-RECORD.
120+
MOVE ACCT-NO TO ACCT-NO-O.
121+
MOVE ACCT-LIMIT TO ACCT-LIMIT-O.
122+
MOVE ACCT-BALANCE TO ACCT-BALANCE-O.
123+
MOVE LAST-NAME TO LAST-NAME-O.
124+
MOVE FIRST-NAME TO FIRST-NAME-O.
125+
MOVE COMMENTS TO COMMENTS-O.
126+
WRITE PRINT-REC.
127+
5000-WRITE-RECORD-END.
128+
*
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
//CBL0003J JOB 1,NOTIFY=&SYSUID
22
//***************************************************/
33
//COBRUN EXEC IGYWCL
4-
//COBOL.SYSIN DD DSN=&SYSUID..CBL(CBL0001),DISP=SHR
5-
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(CBL0001),DISP=SHR
4+
//COBOL.SYSIN DD DSN=&SYSUID..CBL(HELLO),DISP=SHR
5+
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(HELLO),DISP=SHR
66
//***************************************************/
77
// IF RC = 0 THEN
88
//***************************************************/
9-
//RUN EXEC PGM=CBL0001
9+
//COBRUN EXEC IGYWCL
10+
//COBOL.SYSIN DD DSN=&SYSUID..CBL(CBL0003),DISP=SHR
11+
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(CBL0003),DISP=SHR
12+
//LKED.SYSLIB DD DSN=&SYSUID..LOAD(HELLO),DISP=SHR
13+
//***************************************************/
14+
// IF RC = 0 THEN
15+
//***************************************************/
16+
//RUN EXEC PGM=CBL0003
1017
//STEPLIB DD DSN=&SYSUID..LOAD,DISP=SHR
11-
//ACCTREX DD DSN=&SYSUID..DATA,DISP=SHR
18+
//ACCTREC DD DSN=&SYSUID..DATA,DISP=SHR
1219
//PRTLINE DD SYSOUT=*,OUTLIM=15000
1320
//SYSOUT DD SYSOUT=*,OUTLIM=15000
1421
//CEEDUMP DD DUMMY
1522
//SYSUDUMP DD DUMMY
1623
//***************************************************/
1724
// ELSE
1825
// ENDIF
26+
// ELSE
27+
// ENDIF
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//CBL0003J JOB 1,NOTIFY=&SYSUID
2+
//***************************************************/
3+
//COBRUN EXEC IGYWCL
4+
//COBOL.SYSIN DD DSN=&SYSUID..CBL(CBL0001),DISP=SHR
5+
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(CBL0001),DISP=SHR
6+
//***************************************************/
7+
// IF RC = 0 THEN
8+
//***************************************************/
9+
//RUN EXEC PGM=CBL0001
10+
//STEPLIB DD DSN=&SYSUID..LOAD,DISP=SHR
11+
//ACCTREX DD DSN=&SYSUID..DATA,DISP=SHR
12+
//PRTLINE DD SYSOUT=*,OUTLIM=15000
13+
//SYSOUT DD SYSOUT=*,OUTLIM=15000
14+
//CEEDUMP DD DUMMY
15+
//SYSUDUMP DD DUMMY
16+
//***************************************************/
17+
// ELSE
18+
// ENDIF

0 commit comments

Comments
 (0)