Previous Topic Next topic Print topic


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".

    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 to navigate to a certain line in the code.

  • Click Edit > Navigate To and start typing a search term:

Exploring data in editing mode
  1. Open the ZBNKEXT1.cbl file, and scroll down the code to line 24700.
  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.

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.
Smart editing
Let's look at is Smart Editing with background COBOL parsing:
  1. Scroll down to line 25000 in the ZBNKPRT1.cbl file and start typing the following, starting in area A of the code, one character at a time:
    MOVE W TO

    Notice how the words you type change in the editor. Once a word is recognized as a reserved word or a data item, its color changes. If a line of code contains invalid COBOL syntax, the word that is not recognized is underlined with a wavy red line. You can check the Error List window to see what errors are reported.

  2. Change the line to:
    MOVE 34 TO WS-
  3. If you have changed this COBOL program, copy the backup version back in again.
Renumbering the COBOL sources
You can use the commands Renumber and Unnumber to insert and remove line numbers from your code. Your sources include some comments beyond column 73, so you need to configure the line numbering in order to ensure you only apply changes to the COBOL sequence area:
  1. Click Tools > Options > Text Editor > Micro Focus COBOL > Line Numbering.
  2. Ensure that only the COBOL (left margin) option is enabled and that Standard (right margin) is disabled.
  3. Click OK.

You can now remove the line numbers from your code - note that the Renumber and Unnumber commands are not available in the expanded copybook view.

  1. Right-click the ZBNKPRT1.cbl file in the editor, and click Unnumber.

    This removes the line numbers from the COBOL sequence area.

To reinsert the line numbers in your code:

  1. Right-click the ZBNKPRT1.cbl file in the editor, and click Renumber.

To insert line numbers beyond the end of area B:

  1. Click Toggle Standard line numbering mode Toggle Standard line numbering mode on the COBOL toolbar to quickly enable the standard line numbering - this is equivalent to enabling Standard (right-hand margin) in the IDE options.
  2. Right-click the ZBNKPRT1.cbl file in the editor, and click Renumber.

    You should now see line numbers running down both sides of the source code:

    COBOL line numbering
  3. Click Edit > Undo to revert your changes to the file.

JCL editing

  1. Double-click the JCL file in Solution Explorer to open it in the JCL editor.

The editor lets you edit JCL files in text view and offers a basic level of colorization for items such as reserved words and comments. The JCL editor does not support background parsing or syntax checking.

BMS editing

There are two ways to edit BMS files. The first one is to use the basic BMS text editor available in the IDE. The other is to use a WYSIWYG version, the Micro Focus BMS Painter, which is available as a separate utility installed with this product.

To open the BMS file in the IDE text view:

  1. In Solution Explorer, double-click MBANK10.bms to open it in the basic BMS editor.

Although you can use this basic text editor to make small changes, it is quite difficult to edit BMS files in text view.

A much more suitable and less error-prone way to edit BMS files is to use the BMS Painter.

  1. In Solution Explorer, right-click MBANK10.bms and click Open BMS Painter.

    This starts the external Micro Focus BMS Painter.

  2. In BMS Painter, you can click fields and move them by dragging.

    For example, double-click the data field immediately following the text “User Id” and move it to a different position on the map.

  3. To add a field, click in the desired place in the window and start typing.
  4. To change a field's properties, right-click it and select Properties.
  5. To change the properties of the map or mapset, right-click the item and select Properties.

    For example, do this for the MBANK10 mapset and the BANK10A map.

  6. Click File > Exit to close the utility and do not save the file.

Editing data files

You can edit data files using one of two available Micro Focus Data File Editor tools.

  1. In Solution Explorer, right-click the .dat file and click Open File in Data Tools.

  2. The Classic Data File Editor opens the data file and shows two views:
    • The left-hand pane shows the raw form of the file. Because many of the field are COMP-3 fields, the data in these fields is presented in an ASCII view.
    • The right-hand pane shows the record layout for the file in its detailed field view and the COMP-3 fields are shown in a much better, editable form.

  3. Change the value of BAC-REC-BALANCE from 91.14 to 132.76 as follows:
    1. Double-click in the Value field for BAC-REC-BALANCE. You may get an Update warning dialog box when you start typing the new value.
    2. Click Yes to confirm you want to make changes.
    3. Position the cursor in front of the third number before the decimal point and start typing.
    4. Press Enter to confirm the change.
  4. Close the Classic Data File Tools utility without saving your changes.
Previous Topic Next topic Print topic