VS Code Syntax Support for CICS COBOL Statements

Dana Boudreau
Modern Mainframe
Published in
4 min readNov 12, 2020

Advanced edit capabilities for CICS statements are not a native part of the COBOL language editors. Like the COBOL compiler, a modern COBOL edit environment requires an additional translator. So, if you are working on a COBOL program that runs in CICS you will want the advanced capabilities to work on the CICS statements as well as the native COBOL code.

Now available in Visual Studio Code or Eclipse Che as part of the COBOL Language Support extension, COBOL language support is integrated with other mainframe software development capabilities as part of the no-fee Broadcom Code4z extension pack.

In this article, I will show you how easy it is to write CICS code in COBOL programs using cool new edit features like syntax analysis, autocompletion and variable support. COBOL Language Support is an extension available on the VS Code Marketplace. You can find it here.

EXEC CICS is not in the Twilight Zone Anymore

CICS (Customer Information Control System) is a transactional runtime for mainframe application programs. COBOL is one of the languages these applications are often written in. For a COBOL program to use the services of CICS, the program uses EXEC CICS statements.

EXEC CICS command-name command-options

END-EXEC

Example EXEC CICS statement (from IBM Knowledge center)

Visual Studio Intellisense is a great feature that provides the developer with suggested command completions as they type. With the Code4z Cobol LS you now get the added support of EXEC CICS statements. As you type an EXEC CICS statement suggested completions will appear. As you continue to type more precise suggestions appear or you can select one of the already listed suggestions.

If you make a mistake or a typo while writing a CICS statement, you will see a syntax error:

Fortunately, autocomplete makes it a little easier.

Avoid statements that make no sense.

Define in COBOL — Use in CICS

The extension will also resolve CICS command data values that have been defined in the WORKING-STORAGE SECTION or a copybook. If you use a data definition entry in the EXEC CICS statement, it will work the same way for the rest of the document and show up in autocomplete suggestions. This helps resolve variable dependencies and make sure the spelling is correct. You can also use “Go to Definition” and “Find All References” on any instance of the data value. So if you have an existing variable but you don’t remember how it is defined or how it may be used in the code.

If you do not define the data value before using it, you will see a semantic error:

The same for HANDLE CONDITION: “Go to Definition” will bring you to the paragraph:

How to Create a Personal Snippet

A final trick for today: if you use EXEC CICS a lot, it would be handy to create a coding template that can easily be reused then create a special snippet for it.

Go to File > Preferences > User Snippets, choose “COBOL” and add the following text there:

“exec cics” : {

“prefix”: “exec”,

“body”: “EXEC CICS $1 END-EXEC.”,

“description”: “EXEC CICS statement”

}

Save and have fun! Find more details about snippets go here.

Give Code4z a try and give us some feedback. Help out our fellow COBOL developers and contribute to the open source. To report issues or suggest enhancements, visit our GitHub repository using the following link: https://github.com/eclipse/che-che4z-lsp-for-cobol/issues

Further Information

For more information about the other capabilities in Code4z including advanced COBOL edit highlighting, syntax check and intellisense see VS Code for mainframe development or LSP Magic — Mainframe Language Support in Modern IDEs . Learn more about Zowe and Zowe explorer at Beginner’s Guide: COBOL Made Easy or Beginner’s Guide: COBOL Made Easy (Leveraging Open Source Tools). Other Broadcom VS Code extensions

--

--