Skip to content

Commit d9ce50d

Browse files
Merge pull request #153 from klausmelcher/issues-contributions
Contribution to Issue #112
2 parents ed65319 + 2272f4f commit d9ce50d

File tree

4 files changed

+195
-12
lines changed

4 files changed

+195
-12
lines changed

COBOL Programming Course #1 - Getting Started/COBOL Programming Course #1 - Getting Started.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ The lab associated with this chapter demonstrates the ‘end-of-file’ COBOL co
21582158

21592159
- CBL0002J
21602160

2161-
- CBL0003J
2161+
- CBL0033J
21622162

21632163
![](Images/image133.png)
21642164

@@ -2205,10 +2205,10 @@ The lab associated with this chapter demonstrates the ‘end-of-file’ COBOL co
22052205

22062206
- RUN:PRTLINE(103) is the COBOL program execution output (if correction is successful)
22072207

2208-
10. Submit job, JCL(CBL0003J), using the DATA SET section.
2208+
10. Submit job, JCL(CBL0033J), using the DATA SET section.
22092209

22102210

2211-
11. View CBL0003J ABENDU4038 output, using the JOBS section:
2211+
11. View CBL0033J ABENDU4038 output, using the JOBS section:
22122212

22132213
- View the IGZ00355 abend message in RUN:SYSOUT(104) from the COBOL program execution output.
22142214

@@ -2220,33 +2220,33 @@ The lab associated with this chapter demonstrates the ‘end-of-file’ COBOL co
22202220

22212221

22222222

2223-
12. Fix this error by editing JCL(CBL0003J):
2223+
12. Fix this error by editing JCL(CBL0033J):
22242224

22252225
- Determine the DDNAME needed, but missing or misspelled.
22262226

22272227
- Correct it within the code and save
22282228

22292229

22302230

2231-
13. Re-submit job, JCL(CBL0003J), using the DATA SET section.
2231+
13. Re-submit job, JCL(CBL0033J), using the DATA SET section.
22322232

22332233

22342234

2235-
14. View CBL0003J output using the JOBS section, your output should look like Figure 12.
2235+
14. View CBL0033J output using the JOBS section, your output should look like Figure 12.
22362236

22372237
- RUN:PRTLINE - COBOL program execution output (if correction is successful)
22382238

22392239
![](Images/image138.png)
22402240

2241-
*Figure 12. RUN:PRTLINE(103) for JCL(CBL0003J)*
2241+
*Figure 12. RUN:PRTLINE(103) for JCL(CBL0033J)*
22422242

22432243
**Lab hints**
22442244

22452245
13. The error is located on line 11, adjust 'ACCTREX' accordingly.
22462246

22472247
![](Images/image140.png)
22482248

2249-
*Figure 13. Error in id.JCL(CBL0003J).jcl*
2249+
*Figure 13. Error in id.JCL(CBL0033J).jcl*
22502250

22512251
\newpage
22522252

@@ -2300,6 +2300,7 @@ In this chapter we discuss the concept of structured programming and how it rela
23002300
- **Specifying the return value**
23012301

23022302
- **Summary**
2303+
- **Lab**
23032304

23042305

23052306
## Styles of programming
@@ -2778,6 +2779,33 @@ Finally, the RETURNING phrase is used to specify the variable that should be use
27782779

27792780
In summary, this chapter should provide the necessary foundation to understand structured programming and how it relates to COBOL and its importance to understanding and maintaining code. Many examples of how, when and why to implement key techniques have been provided and explained for further understanding. You should be able to identify the basic differences between structured programming (COBOL) and OO programming (Java). You should also understand the general concept of the best practices in the structure of the Procedure Division with reference to the design and content of paragraphs, program control options and ways to call other programs within the same system.
27802781

2782+
2783+
## Lab
2784+
2785+
This lab utilizes COBOL program CBL0003, located within your id.CBL data set, as well as JCL job CBL0003J, located within your id.JCL data set. The JCL jobs are used to compile and execute the COBOL programs, as discussed in previous chapters.
2786+
2787+
#### Using VSCode and Zowe Explorer
2788+
2789+
1. Take a moment and look over the source code of the COBOL program provided: CBL0003.
2790+
2791+
2. Compare CBL0003 with CBL0001 and CBL0002 from the previous lab. Do you notice the differences?
2792+
2793+
a. Observe the new COUNTER line within the WORKING-STORAGE > DATA DIVISION.
2794+
2795+
b. Observe the paragraphs are numerated and they are all explicitly ended by a -END sentence.
2796+
2797+
b. Observe the new paragraphs READ-FIRST-RECORD, READ-TEN-RECORDS, READ-ANOTHER-RECORD, READ-NEXT-RECORDS and CALLING-SUBPROGRAM within the PRECEDURE DIVISION.
2798+
2799+
c. These paragraphs perform the same loop as in CBL0001, but using the PERFORM statement in different ways. The CALLING-SUBPROGRAM calls the HELLO program, already presented in the second Lab of this course.
2800+
2801+
3. Submit job: CBL0003J. This JCL first compiles the program HELLO,
2802+
then compiles CBL0003 and links the result of both compilations
2803+
together.
2804+
2805+
4. View CBL0003J output using the JOBS section and open RUN:PRTLINE, observe the report is identical to CBL0001.
2806+
2807+
5. View output of target program HELLO using the JOBS section and open RUN:SYSOUT.
2808+
27812809
\newpage
27822810

27832811
# File output
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)