Skip to content

Commit f85fbc3

Browse files
Merge pull request #86 from MikeBauerCA/Add-CLI-Lab
Add Zowe CLI & Automation Lab Content
2 parents e6b695d + 764849d commit f85fbc3

13 files changed

+152
-0
lines changed

COBOL Programming with VSCode.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,10 @@ This chapter introduces the basics of COBOL syntax. It then demonstrates how to
773773

774774
- **Lab**
775775

776+
- **Lab - Zowe CLI & Automation**
777+
- **Zowe CLI - Interactive Usage**
778+
- **Zowe CLI - Programmatic Usage**
779+
776780

777781
## COBOL characteristics
778782

@@ -1205,6 +1209,154 @@ In this lab exercise you will connect to an IBM Z system, view a simple COBOL he
12051209
28. The following URL is another excellent document describing the above VSCode and Zowe Explore details with examples:
12061210
[https://marketplace.visualstudio.com/items?itemName=Zowe.vscode-extension-for-zowe](https://marketplace.visualstudio.com/items?itemName=Zowe.vscode-extension-for-zowe)
12071211

1212+
## Lab - Zowe CLI & Automation
1213+
In this lab exercise you will use the Zowe CLI to automate submitting the JCL to compile, link, and run the COBOL program and downloading the spool output. Refer to the section on the "Installation of Zowe CLI and Plug-ins" to install Zowe CLI if you have not already done so. Before developing the automation, we will first leverage the Zowe CLI interactively.
1214+
1215+
### Zowe CLI - Interactive Usage
1216+
In this section, we will use the Zowe CLI interactively to view data set members, submit jobs, and review spool output.
1217+
1218+
1. Within VS Code, open the integrated terminal (Terminal -> New Terminal). In the terminal, issue `zowe --version` to confirm the Zowe CLI is installed as depicted in the following figure. If it is not installed, please refer to to the section on the "Installation of Zowe CLI and Plug-ins." Also notice that the default shell selected (outlined in red) is `bash`. I would recommend selecting the default shell as either `bash` or `cmd` for this lab.
1219+
1220+
![](Images/zowe-cli-version.png)
1221+
1222+
*Figure 29. `zowe --version` command in VS Code Integrated Terminal (Shell selection outlined in red)*
1223+
1224+
2. In order for Zowe CLI to interact with z/OSMF the CLI must know the connection details such as host, port, username, password, etc. While you could enter this information on each command, Zowe provides the ability to store this information in configurations commonly known as profiles. Zowe CLI and the Zowe VS Code Extension share profiles. So if you created a connection profile in the first lab, you could naturally leverage it here.
1225+
1226+
To create a LearnCOBOL profile (and overwrite it if it already exists), issue the following command with your system details (using `prompt*` will prompt you for certain fields and not show input):
1227+
1228+
```
1229+
zowe profiles create zosmf LearnCOBOL --host 192.86.32.250 --port 10433 --ru false --user prompt* --pass prompt*
1230+
```
1231+
1232+
Many profiles can be created for interacting with different z/OSMF instances. If this was not your first profile, you will want to set it as the default for the following lab exercises. Issue the following command:
1233+
1234+
```
1235+
zowe profiles set zosmf LearnCOBOL
1236+
```
1237+
1238+
The following figure demonstrates this sequence of commands.
1239+
1240+
![](Images/create-and-set-zosmf-profile.png)
1241+
1242+
*Figure 30. Create and set z/OSMF profile (secure credential store plug-in is in use)*
1243+
1244+
3. Confirm you can connect to z/OSMF by issuing the following command:
1245+
1246+
```
1247+
zowe zosmf check status
1248+
```
1249+
1250+
4. List data sets under your ID by issuing a command similar to (see sample output in the following figure):
1251+
1252+
```
1253+
zowe files list ds "Z80462.*"
1254+
```
1255+
1256+
You can also list all members in a partitioned data set by issuing a command similar to (see sample output in the following figure):
1257+
1258+
```
1259+
zowe files list am "Z80462.CBL"
1260+
```
1261+
1262+
![](Images/zowe-files-list-ds-and-am-commands.png)
1263+
1264+
*Figure 31. zowe files list ds and am commands*
1265+
1266+
5. Next, we will download our COBOL and JCL data set members to our local machine. First, create and open a new folder in your file explorer. Note that you could also create a workspace to manage multiple projects. See the following figure for help:
1267+
1268+
![](Images/vscode-add-folder.png)
1269+
1270+
*Figure 32. File explorer view to demonstrate opening a new folder*
1271+
1272+
Once you have an empty folder opened, return to the integrated terminal, ensure you are in your folder, and issue commands similar to:
1273+
1274+
```
1275+
zowe files download am "Z80462.CBL" -e ".cbl"
1276+
zowe files download am "Z80462.JCL" -e ".jcl"
1277+
```
1278+
1279+
Then open `hello.cbl` in your file explorer. A completed example is shown in the following figure:
1280+
1281+
![](Images/zowe-files-download-am.png)
1282+
1283+
*Figure 33. Download and view data set members using the CLI*
1284+
1285+
6. Next, we will submit the job in member `Z80462.JCL(HELLO)`. To submit the job, wait for it to complete, and view all spool content, issue:
1286+
1287+
```
1288+
zowe jobs submit ds "Z80462.JCL(HELLO)" --vasc
1289+
```
1290+
1291+
We could also perform this step in piecemeal to get the output from a specific spool file. See the next figure for an example of the upcoming commands. To submit the job and wait for it to enter OUTPUT status, issue:
1292+
1293+
```
1294+
zowe jobs submit ds "Z80462.JCL(HELLO)" --wfo
1295+
```
1296+
1297+
To list spool files associated with this job id, issue:
1298+
1299+
```
1300+
zowe jobs list sfbj JOB00906
1301+
```
1302+
1303+
where `JOB00906` was returned from the previous command.
1304+
1305+
To view a specific spool file (COBRUN:SYSOUT), issue:
1306+
1307+
```
1308+
zowe jobs view sfbi JOB00906 105
1309+
```
1310+
1311+
where `JOB00906` and `105` are obtained from the previous commands.
1312+
1313+
![](Images/zowe-jobs-submit-ds-and-view-spool-output.png)
1314+
1315+
*Figure 34. Submit a job, wait for it to complete, then list spool files for the job, and view a specific spool file*
1316+
1317+
If desired, you can also easily submit a job, wait for it to complete, and download the spool content using the following command (see the following figure for the completed state):
1318+
1319+
```
1320+
zowe jobs submit ds "Z80462.JCL(HELLO)" -d .
1321+
```
1322+
1323+
![](Images/zowe-jobs-submit-ds-and-download-spool-output.png)
1324+
1325+
*Figure 35. Submit a job, wait for it to complete, download and view spool files*
1326+
1327+
The Zowe CLI was built with scripting in mind. For example, you can use the `--rfj` flag to receive output in JSON format for easy parsing. See the next figure for an example.
1328+
1329+
![](Images/zowe-jobs-submit-ds-rfj.png)
1330+
1331+
*Figure 36. The `--rfj` flag allows for easy programmatic usage*
1332+
1333+
### Zowe CLI - Programmatic Usage
1334+
In this section, we will leverage the Zowe CLI programmatically to automate submitting the JCL to compile, link, and run the COBOL program and downloading the spool output. Once you have the content locally you could use any number of distributed scripting and testing tools to eliminate the need to manually review the spool content itself. Historically, in Mainframe we use REXX EXEC etc. for automation, but today we are going to use CLI and distributed tooling.
1335+
1336+
1. Since we already have Node and npm installed, let’s just create a node project for our automation. To initialize a project, issue `npm init` in your project’s folder and follow the prompts. You can accept the defaults by just pressing enter. Only the description and author fields should be changed. See the following figure.
1337+
1338+
![](Images/npm-init-example.png)
1339+
1340+
*Figure 37. Use of `npm init` to create `package.json` for the project*
1341+
1342+
2. Now that we have our `package.json` simply replace the `test` script with a `clg` script that runs the following zowe command (replace `Z80462` with your high level qualifier):
1343+
1344+
```
1345+
zowe jobs submit ds 'Z80462.JCL(HELLO)' -d .
1346+
```
1347+
1348+
You can name the script whatever you want. I only suggested `clg` because the `CLG` in the `IGYWCLG` proc (which is what the JCL leverages) stands for compile, link, go. Now, simply issue `npm run clg` in your terminal to leverage the automation to compile, link and run the COBOL program and download the output for review. An example of the completed `package.json` and command execution are shown in the following figure.
1349+
1350+
![](Images/npm-run-clg.png)
1351+
1352+
*Figure 38. Final `package.json` and `npm run clg` execution*
1353+
1354+
3. If you prefer a graphical trigger, you can leverage VS Code as shown in the following figure. Essentially, the CLI enables you to quickly build your own buttons for your custom z/OS tasks. You could also invoke a script rather than a single command to accomodate more complex scenarios.
1355+
1356+
![](Images/npm-run-clg-button.png)
1357+
1358+
*Figure 39. `clg` task triggered via button*
1359+
12081360
\newpage
12091361

12101362
# Data division

COBOL Programming with VSCode.pdf

4.17 MB
Binary file not shown.
704 KB
Loading

Images/npm-init-example.png

657 KB
Loading

Images/npm-run-clg-button.png

267 KB
Loading

Images/npm-run-clg.png

481 KB
Loading

Images/vscode-add-folder.png

108 KB
Loading

Images/zowe-cli-version.png

280 KB
Loading

Images/zowe-files-download-am.png

762 KB
Loading
293 KB
Loading

0 commit comments

Comments
 (0)