Editing COBOL, JCL, BMS, and Data Files

This topic describes the editing features for the various file types used in your project.
Note: We recommend that you create backup copies of all files before you start editing them.

Editing COBOL Files

You are going to explore some of the COBOL editing features using the ZBNKPRT1.cbl program which produces a report from a sequential data file.

  1. In Solution Explorer, double-click ZBNKPRT1.cbl.

    This opens the file in the COBOL editor in Visual Studio.

Expanded Copybook View
  1. Scroll down the file to line 005000 and see some COPY statements.
  2. Right-click the line for COPY CDATED and click Show "CDATED.CPY".

    This expands the copybook directly in the code of ZBNKPRT1.cbl.

  3. You can edit the code of the copybook in the expanded view so introduce an error in the code now.

    This automatically outputs messages in the Error List window about problems that occurred in the code. You can sort the list by file name. Double-clicking the line for an error in the Error List window positions you on the line in the copybook in the expanded view which causes the error.

  4. Close the file.

    The changes you made to the expanded view were applied to the source of the copybook so now you are prompted to save the file - click No.

Unused data
Notice that some data items in the Data Division are greyed out. This is because they are not referenced in the Procedure Division.
Class View
You can view the objects and the members defined in your projects in the standard Class View located in the tabbed window at the top right of the IDE:

If this window is closed, you can open it from View > Class View.

Navigation in the code
Apart from scrolling down the code in the editor, you can use the following features of the IDE:
  • Use the drop-down menus at the top of the editor:

  • In Solution Explorer double-click on DBANK52P.cbl to open the file, and then click on Edit > Go To > Go To Line to specify a line in the code to navigate to.

  • Click Locate definition, Locate Definition, in the COBOL toolbar and start typing a search term:

Exploring data in editing mode
  1. Open the ZBNKEXT1.cbl file, and scroll down the code to line 024700.
  2. Hover over the WS-RECORD-COUNTER2 data item.

    This provides you with details of the location, the size, the format, and the number of times the field is used in the program.

Data definitions
  1. Right-click a data item in the Procedure Division and click Go To Definition.

    This positions the cursor on the line of code where the data item is defined.

Peek definitions
  1. Scroll down to line number 033200.
  2. Right-click WS-CONSOLE-MESSAGE and click Peek Definition.

    This opens a small window embedded in the editor with the definition of the data item.

    You can type in the window, or peek the definition of another data item in it.

Finding all lines where a data item is used
  1. Right-click a data item in the code, and click Find All References.

    This opens the Find Symbol Results window with a list of all occurrences of the data item in the code.

Searching in copybooks
You can search for strings in the copybooks as follows:
  1. Click Edit > Find and Replace > Find in Files.
  2. Set the Look in to COBOL Project Copybook Paths.
  3. Type BTX- in the Find what field.

  4. Click Find All.

    The results are displayed in the Find Results 1 window.

Marking text and block mode
You can use the mouse to mark the text. To make a block selection of the code:
  • Press Alt and drag the selection with the mouse. <