This topic describes the editing features for the various file types (COBOL, JCL, IMS, BMS, and Data Files).
Important: 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.
- In the
Application Explorer view, double-click
ZBNKPRT1.cbl in the
Sources/cbl folder of the project.
This opens the file in the COBOL editor in Eclipse.
- Copybooks
-
- Scroll down the file until you see some COPY statements.
- Press
F4 to open the file in COBOL Copy View, which shows the code of the copybooks expanded in the source file.
The COBOL Copy View is read-only and you cannot edit the code in it. The screen background changes from white to pale yellow.
- Press
Ctrl+F4 to close the COBOL Copy View.
- To edit a copybook, position the cursor on the COPY statement and press
F3 (Go To Definition).
This opens the copybook file in a new tab in the editor.
- Copybook Dependencies
- By expanding a source file node in the
Application Explorer view, you can see a list of all copybooks referenced in the source code, and nested within them any other copybooks referenced
by those copybooks. Double-click a copybook to open it in the editor.
Use the Copybook Dependency view to show where in the source file's structure the COPY statements appear, and which copybooks
they reference. If the Copybook Dependency view is not displayed in the Team Developer perspective, to open this view click
Window > Show View > Other > Micro Focus > Copybook Dependency.
Click a copybook reference in the Copybook Dependency view to locate the associated COPY statement at the appropriate line
in the source code.
- Unused data
- Notice that some data items in the Data Division are crossed out. This is because they are not referenced in the Procedure
Division.
- Program outline
-
- Right-click anywhere in the COBOL editor and select
Quick Outline.
This opens a pop-up with the outline of the program similar to what the Outline view shows.
- Press
Ctrl+O in the pop-up to see a more detailed outline similar to the Program Outline view.
- Double-click an item in the outline to see how the cursor positions itself on the line of code that this outline item refers
to.
- Click on the permanent Outline view.
- Expand and collapse various lines in the Outline view.
- Double-click items in the Outline view to see how the cursor positions itself on the respective line of code that each one
of these outline items refers to and highlights the referenced item in the editor window.
- Click the Sort button () for the Outline to toggle between a physical or alphabetical sequence.
- Hyperlinks
-
- In the editor, scroll down the file to a line in the Procedure Division.
- Press and hold
Ctrl and move your mouse around the code.
This turns the data items and the paragraph names you hover over into hyperlinks.
- Click one of the hyperlinks to position the cursor on the definition of the respective data item or paragraph.
- Viewing data definitions
-
- Hover over a data item in the Procedure Division to see information about the data item and how many times it is used in
the program.
- Clicking a data item or paragraph name highlights all their occurrences in the code.
- Breadcrumbs
- The Toggle Context Breadcrumbs icon () in the toolbar lets you see another view of the program showing the copybooks.
- Click the icon to enable breadcrumbs.
This opens a new toolbar in the editor with the name of your COBOL program.
- Click the arrow to the right of the program name to see a list of copybooks the program uses.
- Click one of these copybooks to load it in a new tab in the editor.
- Marking text and block mode
- You can either use the mouse to mark a block of text or click
to enable
Toggle Block Selection Mode and select square blocks of text. When a selection is made, you can cut or copy it.
- Rename
- You can use rename refactoring to rename all occurrences of a variable:
- Scroll down to line 022000 in the file.
- Double-click
WS-EXEC-PARM-LL to select it and click
Refactor > Rename.
A pop-up is displayed prompting you to enter a new name for the variable.
- Click the down arrow to show the context menu and click
Open Rename Dialog.
- Specify
WS-EXEC-PARM as a
New name in the dialog box and click
Preview.
This opens the
Rename COBOL Element dialog box that enables you to preview and approve
- Click
Cancel as you are not going to apply these changes for this demo.
You can change your Eclipse preferences and rename without the
Rename COBOL Element dialog box. To do this, go to
Window > Preferences > Micro Focus > COBOL > Editor and uncheck
Rename in editor without dialog.
- Smart editing
- Next, we are going to look at
smart editing with background COBOL parsing. First you'll check the IDE preferences for suggestions that Content Assist offers you in the
editor:
- Click
Window > Preferences > Micro Focus > COBOL > Editor > Content Assist.
- Check
Enable auto activation then click
OK.
- Scroll down to line 025000 in the code 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, a red cross appears to the left of the line and the word is underlined
with a wavy red line.
Also, Content Assist automatically displays a pop-up with suggested keywords and names of data items appears as you type.
- Change the line to:
MOVE 34 TO WS-
If the IDE preferences for auto-activation of Content Assist have not been changed, Content Assist opens a list of potential
data names that start with
WS- to choose from. If Content Assist does not display a list, to open it manually click
Ctrl+Space.
- Finally, 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:
- Click
Window > Preferences > Micro Focus > COBOL > Editor > Line Numbering.
- Ensure that only the
COBOL (left-hand margin) option is enabled.
- Click
OK.
You can now remove the line numbers from your code:
- Right-click the
ZBNKPRT1.cbl file in the editor, and click
Unnumber (or, alternatively, click
in the Eclipse toolbar).
This removed the line numbers from the COBOL sequence area.
To reinsert the line numbers in your code:
- Right-click the
ZBNKPRT1.cbl file in the editor, and click
Renumber (or, alternatively, click
in the Eclipse toolbar).
To insert line numbers beyond the end of area B:
- In the IDE preferences for line numbering, check
Standard (right-hand margin).
- Click
OK.
- 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:
- Click
Edit > Undo Typing as necessary to revert your changes to the file.
JCL and IMS editing
- Double-click the JCL file in the Bankdemo project to open it in the associated editor.
The editor supports background parsing, syntax checking, content assist and an outline view like the COBOL Editor does.
Note: You can open and edit DBD, PSB, and MFS files in the same way. The editors open these files in text view and offer a basic
level of colorization for items such as reserved words and comments.
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:
- In the
Application Explorer view, right-click
MBANK10.bms in the
bms folder and click
.
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.
-
Close the BMS text editor. In the
Application Explorer view, right-click
MBANK10.bms in the
bms folder and click
.
This starts the external
Micro Focus BMS Painter.
- 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.
- To add a field, click in the desired place in the window and start typing.
- To change a field's properties, right-click it and select
Properties.
- 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.
- Click
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 the Classic Data File Tools which was available with Net Express and a newer one, called Data File
Tools.
- Double-click the data file in the
Application Explorer view to open it with the editor you have used during your last edit session. By default, this is the
Classic Data File Editor.
Close the utility now as we are going to use the new one for this demonstration.
To use the new editor:
- In the
Application Explorer view, right-click the .dat file and click
Open With > Data File Tools.
This starts the
Data File Editor and loads the .dat file in the
Open Data File dialog box.
- Click
Open Exclusive to load the file.
- 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.
- Change the value of BAC-REC-BALANCE from 91.14 to 132.76 as follows:
- Click the line for BAC-REC-BALANCE in the right pane and then click
,
Edit Record.
This highlights the record.
- Double-click in the
Value field for BAC-REC-BALANCE.
- Type 132.76 then click
,
Save Record.
- Confirm you want to save the changes to this record.
- Using the same method, restore the previous value of BAC-REC-BALANCE.
- Close the Data File Tools utility.