Sitemap
Andrew Smithson

Andrew Smithson

Software Engineer, Gamer, Musician and everything in between. All opinions are my own.

Debugging CICS programs in VS Code

3 min readMay 7, 2024

--

In a recent conference presentation I wanted to be able to show what was happening while a program was running inside my CICS region. While the classic approach of putting log messages out at all the points would show things it lacks some of the interactivity that works well in demos and doesn’t allow you to show what the program is doing at those points.

Instead using a debugger which allows the use of breakpoints and then inspecting the variables to show what is happening gives a better experience and matches what a developer would see when developing their own applications.

The rest of this post will be the steps I took to get things up and running.

Development and Test System

The easiest way to have a mainframe system with all the middleware systems configured along with development tools is to use a Wazi as a Service instance running in IBM Cloud. Following the instructions to get it setup and connected I could connect using a 3270 emulator and SSH.

IDE

As in the title of this post I’m using VS Code as my IDE, mostly because it is configurable enough to work with any of the languages and systems that I need to use on a day to day basis. There are two key extensions that need to be installed for this piece of work

Between them they provide the syntax highlighting and debug integration required to work with a CICS COBOL program.

Compiling the application

The only change required when compiling the application was to add the TEST(SOURCE) option to the compiler options. This ensures that the source code and compiler listings are included in the compiler object ready for the debugger to use when required.

Note you should ensure that these are removed for any programs that you are moving into a production environment.

Connecting the Debugger

To connect to the Debug Server a connection needs to be defined in the Zowe configuration file. I added the following configuration

"zOpenDebug": {
"type": "zOpenDebug",
"properties": {
"host": "IP Address or Hostname",
"dpsPort": 8192,
"dpsContextRoot": "api/v1",
"dpsSecured": true,
"uuid": "5c35b057-b85f-4a8c-8b45-08f615988e35",
"user": "ibmuser",
"rejectUnauthorized": false
}
}

Which then added the connection in the z/OS Debugger Profiles.

Configuring the debug profile

With the connection to the debug server installed it’s time to define the CICS transaction to be debugged. This was done by right-clicking on CICS in the Debug Profiles tree and selecting ‘Create Debug Profile’.

Get Andrew Smithson’s stories in your inbox

Join Medium for free to get updates from this writer.

In the editor that opens I needed to select the CICS region in which the transaction will run, the name of the transaction and the user who will be running the transaction.

Press enter or click to view image in full size
Debug Profile Editor

Debug the program

To debug the program the transaction was started from a 3270 terminal at which point it appeared to hang. Going back VS Code in the Debug panel there is the option to connect to a parked session.

Press enter or click to view image in full size

Running this debug profile connects to the Debug Server and drops us into standard debug view where breakpoints can be set, variables inspected and the code stepped over as required.

Press enter or click to view image in full size

Conclusion

Using the IBM Z Open Debug extension in VS Code provides the same debug experience as you get for other languages and offers a great way to understand what your code is doing while running.

--

--

Written by Andrew Smithson

Software Engineer, Gamer, Musician and everything in between. All opinions are my own.