Setting tabs

The LPEX editor COBOL parser sets tabs at columns 1, 7, 8, 12 and every 4 characters after column 12. The LPEX editor Tabs preference settings are ignored in COBOL files open in the z Systems® LPEX Editor.

Procedure

Use the set tabs line command to set and query tabs in COBOL files. For more information about setting and querying tabs, see to the following topics:

Adding and removing comments

When you edit COBOL files in the z Systems LPEX Editor, you can use editor actions to add or remove comments for one or more lines.

Procedure

  1. To add comments:
    1. Highlight one or more lines that you want to make into a comment.
    2. Right-click and click Source > Comment.
  2. To remove comments:
    1. Highlight one or more comment lines from which you want to remove the comment tag.
    2. Right-click and select Source > Uncomment.

Searching for occurrences of code elements

The search for occurrences action in the editor locates related language elements. You can select an element in the code and other instances are displayed in the Search view and highlighted in the editor. The results from a search occurrence action also contain occurrences present in copy members, include members, and identified preprocessor statements.

About this task

The scope of elements that can be located by using the search for occurrences is different for COBOL and PL/I programs as shown in the following table.
Table 1. Supported program elements
COBOL PL/I
  • Procedural Statement Conditions
  • Procedural End phrases
  • User-defined words
  • IF Statement
  • WHEN statements
  • OTHERWISE statements
  • Matching END statements
  • Variables and labels

In the Search view, read instances and write instances are highlighted differently. Instances that are reads are highlighted in gray and write instances are highlighted in gold.

The mark occurrence and search occurrence actions are similar in that both provide a method to locate related language elements. But they have several differences:
  • Results of a search occurrences operation are included in the Search view along with being highlighted in the editor. The results of a mark occurrence action are included in the editor only.
  • The results of a search occurrences operation include occurrences in copy members, include members, and identified preprocessor statements. These occurrences are not provided in the mark occurrence results.
  • The mark occurrence action is limited to elements selected on the Mark Occurrences preference.

Procedure

  1. In the file, highlight the code element for which you want to locate other occurrences and right-click.
  2. Click Occurrences in Compilation Unit.
    The Search view displays the found occurrences in the file. Instances of the elements are highlighted as follows:
    • Write instances are highlighted in orange.
    • Read instances are highlighted in gray.
  3. To locate the occurrence in the file, double-click in the code element Search view.

Real-time syntax checking of COBOL files

Real-time syntax checking automatically validates the syntax of COBOL code and embedded CICS® and SQL statements.

About this task

Supported Editors:
  • COBOL Editor
  • z System LPEX Editor

The editor performs real-time syntax checking and provides annotations that describe the errors. If an error is found, a warning icon (Exclamation mark in yellow triangle) is displayed. To see the annotation that describes the error, hover your mouse over the icon. The maximum number of errors that are reported is based on the value that is specified for the Maximum number of problems reported per compilation unit option on the Real-Time Syntax Checking preference page. The maximum includes the file content and referenced files.

You can customize the appearance of the annotation. The default appearance is a yellow squiggly line under the detected error. To customize, click Editor > Text editors > Annotation in the Preferences window. Then, select Exclamation mark in yellow triangle Warnings in the annotation types list. Change the appearance by selecting values under Show in. For example, to highlight the error, check the Text as box and select Highlighted from the menu. Use the Color field to define the highlight color.

To turn off real-time syntax checking, select Disable syntax parser on the Real-Time Syntax Checking preference page. To enable or disable SQL annotations, use the EXEC SQL statements preference page.

The editors check for the following error types in COBOL source files:
  • COBOL syntax errors
  • Missing copybook files
  • Undeclared variables
  • CICS syntax errors in EXEC CICS blocks
  • IMS syntax errors in EXEC DLI blocks
  • Ambiguous variable references
  • Unreachable code. This error type is identified in v14.1.6 and later versions of the product.
Limitations:
  • Real-time syntax checking is not a substitute for compiling. Real-time syntax checking can catch most high-level syntax errors, but for full error checking, it is best to compile your source code.
  • For real-time syntax checking to handle COPY statements correctly, the statement must end with a period (.).

Example

The following example shows the annotation for a syntax error.
Division expected instead of this input annotation.
The code contained the following statement:
Syntax error in COBOL program. Statement coded is incorrect.
The IDENTIFICATION statement must contain "DIVISION" instead of "DIV". The annotation appearance is a green highlight.
The following example shows a missing COPYBOOK. The appearance for this annotation is the default appearance.
Annotation for missing COPYBOOK

Editing a COBOL source file that references a modified copybook

You can split the editor screen to search for and edit fields that reference copybooks.

Before you begin

You must first locate the file that you want to change. If the file is on a remote system, you must be connected to the system first.

Procedure

  1. Open the file.
  2. Perform a search for the field that references the copybook.
  3. Continue the search until you locate the place you want to change.
  4. To split the editor screen, right-click in the editor and click View->Open new view. The editor displays the source file in two panes side by side.
  5. You can use the one pane for reference while you edit in the other pane. The contents of the two panes are synchronized in such a way that the editing changes in one show up in the other at the same time.