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 with VSCode.md
+159-6Lines changed: 159 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -911,6 +911,8 @@ Open VSCode and in the left side tool menu select **Extensions**. From there, i
911
911
912
912
*Figure 3. Install Zowe Explorer in VSCode*
913
913
914
+
The Zowe communinity have a number of on-line video that walk through the steps required to install, configure and operate the Zowe Explorer, see [Zowe Explorer VSC Extension (part 1)](http://www.youtube.com/watch?v=G_WCsFZIWt4&t=0m38s).
915
+
914
916
### IBM Z Open Editor
915
917
916
918
IBM Z Open Editor brings COBOL and PL/I language support to Microsoft VSCode. It is one of the several next generation capabilities for an open development experience for z/OS®. It also works in association with the Zowe Explorer plugin. For more information on IBM Z Open Editor, please visit:
@@ -1106,6 +1108,10 @@ This chapter introduces the basics of COBOL syntax. It then demonstrates how to
1106
1108
1107
1109
-**Lab**
1108
1110
1111
+
-**Lab - Zowe CLI & Automation**
1112
+
-**Zowe CLI - Interactive Usage**
1113
+
-**Zowe CLI - Programmatic Usage**
1114
+
1109
1115
1110
1116
## COBOL characteristics
1111
1117
@@ -1322,7 +1328,7 @@ Three ‘Enterprise COBOL for z/OS” manuals are referenced throughout the chap
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.
1549
+
1550
+
### Zowe CLI - Interactive Usage
1551
+
In this section, we will use the Zowe CLI interactively to view data set members, submit jobs, and review spool output.
1552
+
1553
+
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.
1554
+
1555
+

1556
+
1557
+
*Figure 29. `zowe --version` command in VS Code Integrated Terminal (Shell selection outlined in red)*
1558
+
1559
+
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.
1560
+
1561
+
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):
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:
1568
+
1569
+
```
1570
+
zowe profiles set zosmf LearnCOBOL
1571
+
```
1572
+
1573
+
The following figure demonstrates this sequence of commands.
1574
+
1575
+

1576
+
1577
+
*Figure 30. Create and set z/OSMF profile (secure credential store plug-in is in use)*
1578
+
1579
+
3. Confirm you can connect to z/OSMF by issuing the following command:
1580
+
1581
+
```
1582
+
zowe zosmf check status
1583
+
```
1584
+
1585
+
4. List data sets under your ID by issuing a command similar to (see sample output in the following figure):
1586
+
1587
+
```
1588
+
zowe files list ds "Z80462.*"
1589
+
```
1590
+
1591
+
You can also list all members in a partitioned data set by issuing a command similar to (see sample output in the following figure):
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:
1602
+
1603
+

1604
+
1605
+
*Figure 32. File explorer view to demonstrate opening a new folder*
1606
+
1607
+
Once you have an empty folder opened, return to the integrated terminal, ensure you are in your folder, and issue commands similar to:
1608
+
1609
+
```
1610
+
zowe files download am "Z80462.CBL" -e ".cbl"
1611
+
zowe files download am "Z80462.JCL" -e ".jcl"
1612
+
```
1613
+
1614
+
Then open `hello.cbl` in your file explorer. A completed example is shown in the following figure:
1615
+
1616
+

1617
+
1618
+
*Figure 33. Download and view data set members using the CLI*
1619
+
1620
+
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:
1621
+
1622
+
```
1623
+
zowe jobs submit ds "Z80462.JCL(HELLO)" --vasc
1624
+
```
1625
+
1626
+
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:
1627
+
1628
+
```
1629
+
zowe jobs submit ds "Z80462.JCL(HELLO)" --wfo
1630
+
```
1631
+
1632
+
To list spool files associated with this job id, issue:
1633
+
1634
+
```
1635
+
zowe jobs list sfbj JOB00906
1636
+
```
1637
+
1638
+
where `JOB00906` was returned from the previous command.
1639
+
1640
+
To view a specific spool file (COBRUN:SYSOUT), issue:
1641
+
1642
+
```
1643
+
zowe jobs view sfbi JOB00906 105
1644
+
```
1645
+
1646
+
where `JOB00906` and `105` are obtained from the previous commands.
*Figure 34. Submit a job, wait for it to complete, then list spool files for the job, and view a specific spool file*
1651
+
1652
+
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):
*Figure 35. Submit a job, wait for it to complete, download and view spool files*
1661
+
1662
+
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.
1663
+
1664
+

1665
+
1666
+
*Figure 36. The `--rfj` flag allows for easy programmatic usage*
1667
+
1668
+
### Zowe CLI - Programmatic Usage
1669
+
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.
1670
+
1671
+
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.
1672
+
1673
+

1674
+
1675
+
*Figure 37. Use of `npm init` to create `package.json` for the project*
1676
+
1677
+
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):
1678
+
1679
+
```
1680
+
zowe jobs submit ds 'Z80462.JCL(HELLO)' -d .
1681
+
```
1682
+
1683
+
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.
1684
+
1685
+

1686
+
1687
+
*Figure 38. Final `package.json` and `npm run clg` execution*
1688
+
1689
+
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.
1690
+
1691
+

1692
+
1693
+
*Figure 39. `clg` task triggered via button*
1694
+
1541
1695
\newpage
1542
1696
1543
1697
# Data division
@@ -2528,7 +2682,7 @@ This may seem complex, but compare it to this Java pseudo-code:
2528
2682
2529
2683
```
2530
2684
for(int counter = 0; counter < 11; counter++){
2531
-
for(int counter-2 = 0; counter < 5; counter++{
2685
+
for(int counter2 = 0; counter2 < 5; counter2++{
2532
2686
//move counter to msg-to-write
2533
2687
//write print-rec
2534
2688
}
@@ -3762,7 +3916,7 @@ This section will cover the necessary steps and information to download and inst
3762
3916
3763
3917
From the link below, you will find the requirements for installing and running IDz on the different supported OS platforms: Windows, Linux, Mac and z/OS. Select your proper platform and verify that your system meets the operating systems and hardware minimum requirements.
0 commit comments