You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: COBOL Programming Course #2 - Advanced Topics/COBOL Programming Course #2 - Advanced Topics.md
+184-9Lines changed: 184 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,16 +19,190 @@ header-includes:
19
19
linkcolor=blue}
20
20
---
21
21
\newpage
22
-
# COBOL Challenges
22
+
# COBOL Application Programming Interface (API)
23
+
API is the acronym for Application Programming Interface. An API allows two applications to communicate. We use API's everyday from our phones, personal computers, using a credit card to make a payment at a point of sale, etc.
24
+
25
+
Today's digital infrastructure is instrumented and interconnected. It is the API's that enable the "instrumented" network to be "interconnected". As a result, API has become a highly used acronym in the technology arena. The phrase "API Economy" became strategic term since Forbes declared 2017 "The Year of the API Economy".
26
+
27
+
Business application solutions were architected decades ago using programming language API's. Long before API became a strategic technology category, mainframe application developers understood the acronym as a way to enable a programming language to communicate with other software. The value of being a programmer in any specific programming language increased by understanding and using API's.
28
+
29
+
-**Enterprise COBOL APIs**
30
+
-**z/OS Middleware**
31
+
-**COBOL API Communication with Middleware**
32
+
-**COBOL EXEC SQL**
33
+
-**COBOL Data Items**
34
+
35
+
-**SQL Capability within Enterprise COBOL**
36
+
-**Enterprise COBOL Application Programming and SQL Guide**
37
+
-**Db2 Data Base Administration (DBA) vs Application Programming**
38
+
39
+
-**Lab**
40
+
-**Using VSCode and Zowe Explorer**
41
+
42
+
## Enterprise COBOL APIs
43
+
IBM mainframe flagship operating system, z/OS, includes software that has enabled large scale business applications for decades. The software is frequently referred to as 'middleware'. Examples of z/OS 'middleware' is Db2, a relational database, CICS, transactional processor, IMS, both transactional and hierarchical database, and MQSeries, a mechanism to store and forward data between systems asynchonously.
44
+
45
+
### z/OS Middleware
46
+
A fundamental capability of z/OS middleware software is communication enablement of programming languages. The z/OS middleware software includes documentation and examples of how any specific programming language can communicate with the specific z/OS middleware software. A programming language, such as Enterprise COBOL, would use documented interfaces and techniques to initiate services and pass data between the COBOL application program and the middleware.
47
+
48
+
### COBOL API Communication with Middleware
49
+
Each middleware has unique reserved words available to Enterprise COBOL.
50
+
51
+
Enterprise COBOL unique API reserved words are in Example 1.
52
+
53
+
```
54
+
EXEC SQL
55
+
EXEC CICS
56
+
CALL 'MQ...'
57
+
CALL 'CBLTDLI'
58
+
```
59
+
*Example 1. COBOL API Reserved Words*
60
+
61
+
Each of the above COBOL API's enable the program to communcate with Db2, CICS, MQSeries, and IMS respectively. When the COBOL source program is compiled, the API reserved words expand the number of lines in the COBOL source code. The expanded lines of code does not need to be fully understood by the COBOL programmer. The COBOL programmer uses an API to accomplish a task within the logic and the middleware expanded code follows through with accomplishing the task.
62
+
63
+
### COBOL EXEC SQL
64
+
SQL, Structured Query Language, is the documented standard for communicating will all relational databases. Enterprise COBOL is capable of including Db2 for z/OS SQL. A few simple COBOL EXEC SQL reserved words are shown in Example 2.
EXEC SQL FETCH CUR1 INTO :CUSTOMER-RECORD END-EXEC.
99
+
PERFORM PRINT-AND-GET1
100
+
UNTIL SQLCODE IS NOT EQUAL TO ZERO.
101
+
EXEC SQL CLOSE CUR1 END-EXEC.
102
+
```
103
+
*Example 2. COBOL SQL Statements*
104
+
105
+
### COBOL Data Items
106
+
While the EXEC SQL is expanded into additional lines of code at compile time,
107
+
COBOL needs data items to manage the data passed between the COBOL program and Db2 table.
108
+
109
+
The fields in the Db2 table record were defined using CREATE TABLE SQL. The EXEC SQL DECLARE in Table xx describes the Db2 table format within the COBOL program. The COBOL programmer with knowledge of the Db2 table format can code the table format or let Db2 for z/OS generate the code using a DCLGEN utility.
110
+
111
+
Observe ":CUSTOMER-RECORD" in the EXEC SQL FETCH statement. A colon (:) precedes COBOL program defined variables that are used in SQL statements so that Db2 can distinguish a variable name from a column name. Example 3. shows the COBOL program data items describing the COBOL program variable names.
*Example 3. COBOL Data Item for storing variables where Db2 is the data source*
130
+
131
+
## SQL Capability within Enterprise COBOL
132
+
Learning SQL is a separate technical skill. The objective of this brief chapter is familiarization with Enterprise COBOL use of SQL API. A COBOL program is capable of any SQL communication with Db2 for z/OS assuming necessary authority is granted. SQL has four catagories as outlined in Example 4. Learning SQL is necessary for a COBOL programmer to become proficient with using the Db2 API for a variety of possible applications where COBOL provides the what, how, and when logic of executing specific SQL.
133
+
134
+
```
135
+
DDL - Data Definition Language
136
+
CREATE
137
+
ALTER
138
+
DROP
139
+
140
+
DML - Data Manipulation Language
141
+
SELECT
142
+
INSERT
143
+
UPDATE
144
+
DELETE
145
+
146
+
DCL - Data Control Langauge
147
+
GRANT
148
+
REVOKE
149
+
150
+
TCL - Transaction Control Language
151
+
COMMIT
152
+
ROLLBACK
153
+
```
154
+
*Example 4. SQL Categories*
155
+
156
+
### Enterprise COBOL Application Programming and SQL Guide
157
+
Db2 for z/OS V12 is the most current release of Db2 at the moment. The Db2 V12 for z/OS Application Programming and SQL Guide is available using internet search SC27-8845, the Db2 for z/OS professional manual number. Db2 V12 for z/OS SQL Reference is also necessary to advance programming API capability (SC27-8859).
158
+
159
+
### Db2 Data Base Administration (DBA) vs Application Programming
160
+
In large enterprise, the roles and responsibilities are divided for a number of reasons. The responsibility of the DBA would include the DDL and DCL outlined in Example 4. The DBA is responsibile for managing the entire relational data base environment to insure availability, security, performance, etc. The system programmers and DBAs frequently setup the application development procedures for COBOL programmer development, testing, and maintenance of the COBOL business applications. A COBOL application programmer is typically provided documented procedures to follow to apply their COBOL programming and SQL API expertise.
161
+
162
+
Enterprise COBOL is a learning journey. Each Enterprise COBOL API is a separate learning journey. As is the case with most professional endeavors, learning, repetition, and applying what is learned is re-iterative process leading to advanced skill levels.
163
+
164
+
## Lab
165
+
The lab contains data used in previous labs from "COBOL Programming Course #1 - Getting Started" where the data source was sequential data set, then a VSAM data set. The lab provides JCL to create a personal Db2 table in a DBA-created database name using a DBA-created storage group. The DBA-created storage group directs the create tablespace and table to specific disk storage volumes.
166
+
167
+
The lab contains Enterprise COBOL source code with Db2 APIs along with the JCL to compile and execute the COBOL programs.
168
+
169
+
### Using VSCode and Zowe Explorer
170
+
Zowe Explorer is currently without the ability to execute Db2 SQL interactively. It is inevitable Zowe Explorer will eventually have the capability of connectiong to relational databases and executing SQL.
171
+
172
+
Therefore, JCL members were created to create and load user tables following examples provided.
173
+
174
+
1. Submit `zos.public.db2.jcl(db2setup)`
175
+
The result is new JCL and CBL members copied into personal JCL and CBL libraries
176
+
177
+
2. SUBMIT JCL(CRETBL)
178
+
The result is a personal Db2 tablespace, table, indexspace, and index
179
+
180
+
3. SUBMIT JCL(LOADTBL)
181
+
The result is data loaded into the personal Db2 tablespace, table, indexspace, and index
182
+
183
+
4. Edit each COBOL source code member in your CBL partition data set changing all occurrences of Z# to your personal ID. Example - If your ID was Z80001, then change all occurrences of Z# to Z80001.
184
+
185
+
5. SUBMIT JCL(CBLDB21C)
186
+
The result is compile of CBL program CBLDB21 and a Db2 Plan needed for program execution
187
+
188
+
6. SUBMIT JCL(CBLDB21R)
189
+
The result is execution of COBOL program CBLDB21 to read the Db2 table and write each record from the Db2 table .
23
190
24
-
As you have now handled some basic exercises, we have prepared a new section containing more advanced exercises that test your ability to resolve bugs and other issues in COBOL programs. Each exercise will have a short description and a goal to be accomplished.
191
+
7. Two additional COBOL programs with Db2 API exist, CBLDB22 and CBLDB23 using the same Db2 table as the data source.
25
192
26
-
In case you get stuck, a blog with instructions will be published shortly after each exercise.
193
+
194
+
\newpage
195
+
# COBOL Challenges
196
+
As you have now handled some basic exercises, we have prepared a new section containing more advanced exercises that test your ability to resolve bugs and other issues in COBOL programs. Each exercise will have a short description and a goal to be accomplished.
27
197
28
198
Happy Coding!
29
199
30
-
\newpage
200
+
-**COBOL Challenge - Debugging**
201
+
-**COBOL Challenge - The COVID-19 Reports**
202
+
-**COBOL Challenge - The Unemployment Claims**
203
+
-**Hacker News Rankings for Mainframe/COBOL Posts**
31
204
205
+
\newpage
32
206
## COBOL Challenge - Debugging
33
207
34
208
It is 2020 in Washington, D.C. John Doe runs a program which provides financial reports on US Presidents and tallies the number of reports from the state of Virginia. Everything seems OK. (see below)
@@ -49,6 +223,7 @@ Can you fix the code to get the correct result? The new source code is named **C
49
223
50
224
You can find them in the github repository for the COBOL course, in the subfolder **/COBOL Programming Course #2 - Advanced Topics/Challenges/Debugging**.
51
225
226
+
\newpage
52
227
## COBOL Challenge - The COVID-19 Reports
53
228
54
229
Today, you are tasked to create a COVID-19 Summary Report of all the countries around the world, using information from the COVID19API website.
@@ -65,7 +240,7 @@ Today, you are tasked to create a COVID-19 Summary Report of all the countries a
65
240
66
241
3. Using Zowe, upload the CSV file to the mainframe.
67
242
68
-
**Hint:** You can use the command `zowe files ul ftds “file location” “dataset name”` to upload the CSV file to the mainframe.
243
+
**Hint:** You can use the command `zowe files ul ftds "file location" "dataset name"` to upload the CSV file to the mainframe.
69
244
70
245
4. Create a new member in your *.CBL data set to write your COBOL program.
71
246
@@ -107,17 +282,18 @@ If you want a more challenging approach, try the optional tasks below:
107
282
108
283
To check the solution, refer to the blog post [here](https://medium.com/@jessielaine.punongbayan/solution-covid-19-reports-cobol-challenge-6c509579e3fe?source=friends_link&sk=5a662034a03c91d639b77267ed6abfc9).
109
284
110
-
Happy Coding! 😉
285
+
Happy Coding!
111
286
112
287
_Disclaimer: This challenge is also posted in [Medium.com](https://medium.com/@jessielaine.punongbayan/cobol-challenge-covid-19-reports-ee03a946bd23)._
113
288
289
+
\newpage
114
290
## COBOL Challenge - The Unemployment Claims
115
291
116
292
Now let's try a more advanced challenge! Your task is to create an end-to-end solution. Our end goal is to build an application that will fire Zowe APIs to the mainframe and display the result in the application. This is how the flow would look:
117
293
118
294

119
295
120
-
_Of course, you do not have to complete the whole challenge if you do not want to. But it would be great if you do_ 😉
296
+
_Of course, you do not have to complete the whole challenge if you do not want to. But it would be great if you do_
121
297
122
298
### Our Data
123
299
@@ -200,12 +376,11 @@ Add more functionality to your COBOL Sub-routine like:
200
376
201
377
I hope that by taking this challenge, you will be able to learn something new!
202
378
203
-
Happy Coding! 😉
379
+
Happy Coding!
204
380
205
381
_Disclaimer: This challenge is also posted in [Medium.com](https://medium.com/@jessielaine.punongbayan/zowe-cobol-challenge-the-unemployment-claims-2e35a42eabaa)._
Copy file name to clipboardExpand all lines: README.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,3 +36,10 @@ This project is openly governed as defined in [GOVERNANCE.md](GOVERNANCE.md).
36
36
## Credits
37
37
38
38
The courseware materials were made available through a joint collaboration IBM, it's clients, and American River College and proposed as a new project by IBM.
39
+
40
+
## Video Course Links
41
+
42
+
-[IBM Digital Learning Platform](https://learn.ibm.com/course/view.php?id=7552)
Attendees: All Core team members & few community participants
13
+
14
+
1. Core Team members introduced themselves
15
+
2. Sudharsana shared a quick update on COBOL Course
16
+
- requested for community help with getting content added to Course #2
17
+
3. Paul shared that he is working on Disk Storage guidelines and will share soon
18
+
- Request to be mindful when allocating system resources
19
+
4. Mike gave an overview on ZOWE, a sister project on OMP
20
+
5. Dr. Cameron Saey shared about the new initiative called COBOL Working group. This latest initiative on OMP is looking to bring academic attention to COBOL.
Attendees: All Core team members & few community participants
11
+
12
+
1. Core Team members introduced themselves
13
+
2. Mike shared a quick update on COBOL Course
14
+
- requested community participation in building up content for Course #2
15
+
- shared the content in v2.1.0 of the COBOL Course PDF
16
+
3. Radha went over the Db2 work she has been doing - check out a recording [here](https://drive.google.com/file/d/1ufFW1ENFM_3EITLiAlGs7RmhOrfJxfoD/view?usp=sharing)!
17
+
- The recording of the session will be available soon, stay tuned!
18
+
4. Q&A
19
+
- Q: Is this course content is available publicly?
20
+
A: Yes. This is open to anyone and everyone to use in their learning journey. There is also a video course of this COBOL content available
21
+
on IBM Digital Learning Platform at no cost, Coursera and Pluralsight.
22
+
23
+
5. September was a wealth of information shared through these various conferences:
24
+
-[IBM Z Day 2020 Replays](https://ibmzday-vconf.bemyapp.com/#/event)
0 commit comments