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.

    GUID-212C3435-0F2E-487C-BF47-C8E136DBA6D2-low.png

  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.

    GUID-52DEE05F-A293-40FC-85C6-B7EEEC31B3E4-low.png

  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:

GUID-7ABD302A-3A84-45D8-B5CA-A2CFFF4422BE-low.png

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:

    GUID-01BC0AB2-D419-4D70-9BD7-3824AEAB9122-low.png

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

    GUID-6089AD92-B7EB-4E8D-94DE-3B5E54886FCA-low.png

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

    GUID-E9722D86-8CDE-4C44-B011-C70FC26EE376-low.png

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.

    GUID-5C1854F7-FFEF-4F28-BA32-AB9FD35C9E96-low.png

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.

    GUID-6F0E4653-0A83-4A06-BF87-6C56BA8E12B3-low.png

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.

    GUID-7681CF26-3A64-47D2-AB9D-E22A11B4749C-low.png

  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.
Rename items in the code
Try and see how rename factoring works in the IDE:
  1. Click Go To Procedure Division, Go To Procedure Division, in the COBOL toolbar to go to the Procedure Division in the ZVBNKPRT1.cbl file.
  2. Scroll down to line 022000.
  3. Right-click WS-EXEC-PARM-LL and click Rename.

    This opens the Rename dialog box. Note that any changes you make are applied the current program only.

    GUID-6CCFC7C0-94ED-40DF-B949-010D54792F17-low.png

  4. Type WS-EXEC-PARM and click Preview.

    Review the changes and click Apply.

    GUID-20AD975D-6050-47A2-9E82-6D0BDFEB7655-low.png

    All instances of the data item are renamed in the source file.

  5. You can now click Edit > Undo to revert the changes.
Smart editing
Let's look at how Smart Editing works 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 choose from a number of Renumber and Unnumber options available from the COBOL toolbar (use GUID-E5E99C81-B416-4029-9195-2B486F3ED4AE-low.png in the toolbar) to insert and remove line numbers from your code. Your sources include some comments beyond column 73, so you might want to only change the numbers in the COBOL sequence area.

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. Ensure ZBNKPRT1.cbl is opened in the editor, click the downward arrow next to GUID-E5E99C81-B416-4029-9195-2B486F3ED4AE-low.png in the COBOL toolbar and click Unnumber Left.

    This removes the line numbers from the COBOL sequence area.

    GUID-AD1F9571-747C-4711-8DEA-3D52A50E22C6-low.png

To reinsert the line numbers in your code:

  1. Click the downward arrow next to GUID-E5E99C81-B416-4029-9195-2B486F3ED4AE-low.png in the COBOL toolbar and click Renumber Left.

To insert line numbers beyond the end of area B:

  1. Click the downward arrow next to GUID-E5E99C81-B416-4029-9195-2B486F3ED4AE-low.png in the COBOL toolbar and click Renumber Both.

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

    COBOL line numbering

JCL editing

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

    GUID-C8AC0D24-01F4-4DF4-8D7D-3D269421AA4A-low.png

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.

    GUID-6D5E29B1-0154-4E1A-82DA-D2985BBCE770-low.png

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.

    GUID-A5EB7708-0568-4AC2-BB16-5F48217B2BB2-low.png

  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.

Let's configure Visual Studio to use the new Data File Tools utility. You do this in the IDE options:

  1. Click Tools > Options > Micro Focus > Data File Tools.
  2. Disable Use Classic Data File Tools and click OK.
  1. In Solution Explorer, right-click the .dat file and click Open File in Data Tools.

    GUID-D26D8201-1599-46D4-AF76-0B2701014000-low.png

    This starts the Data File Editor and loads the .dat file in the Open Data File dialog box.

  2. Click Open Exclusive to load the file.
  3. Data File Editor loads 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.

    GUID-4F74E741-CDC6-412E-B34C-1F217C3A72EB-low.png

  4. Change the value of BAC-REC-BALANCE from 91.14 to 132.76 as follows:
    1. Click the line for BAC-REC-BALANCE in the right pane and then click Edit Record, Edit Record.

      This highlights the record.

    2. Double-click in the Value field for BAC-REC-BALANCE.
    3. Type 132.76 then click Save Record, Save Record.
    4. Confirm you want to save the changes to this record.
    5. Using the same method, restore the previous value of BAC-REC-BALANCE.
  5. Close the Data File Tools utility.