Running JCL on the Mainframe | Debugging COBOL |
Use the Data Tools in Mainframe Express to convert, browse, edit and create data files used by an application.
Before you do this session, you need to have read the chapter Start Here for the Tutorials and worked through the first session Using Mainframe Express.
Using Data Tools, you can:
Files can be in any COBOL format and you can view them at both the record and field levels.
The demo application used in this session consists of:
The data file is a variable length sequential file, containing details of staff in three record types: employee, manager and executive.
In this session, you:
To save you creating the project used in this session, we supply the project dtoldemo.mvp.
You'll see the demo data file DEMO.SEQ.DAT.
In this session you:
To make a VSAM copy of the supplied sequential file:
The Dataset Convert dialog box appears. If you had selected a file that was not in a catalog, you would have had to confirm the input file header details by clicking Validate under Input file. However, because you have chosen a file from the catalog, MainFrame Express reads the header details for the input file from the catalog entry for DEMO.SEQ.DAT and also copies these details to the output file.
DS Name | DEMO.VSAM.DAT |
---|---|
DSORG | VSAM |
RECFM | KS |
If an entry for a file of that name already existed in the catalog, Convert would ask instead whether to use the details of the existing file.
The field to be used as the primary key is at the beginning of the record, and is seven bytes long.
If you wanted to convert more files, you could have clicked OK instead to return to the Dataset Convert dialog box.
To view the file you just created:
In certain places in Mainframe Express, double-clicking an item executes the first function on the popup menu. Here, you could have double-clicked DEMO.VSAM.DAT instead of right-clicking and clicking Edit.
A Data File Editor window, displaying the contents of DEMO.VSAM.DAT as shown in Figure 12-1, appears.
Figure 12-1: The IDE with a Data File Editor Window
Each record is shown as one line. Because Data File Editor does not know the lengths of the fields in the record, each line is simply a continuous line of text. That is, the records are unformatted. Non-character fields such as COMP items generally display as odd characters, or as if they don't correspond to any printable character.
You can edit the file by typing over the existing data. There are many editing facilities available. For example, the Data Tools option on the Search menu offers four ways of searching a data file:
The status line at the bottom of the IDE shows various statistics, depending on the file details:
The Data File Editor window may have a right-hand pane visible, displaying "A record layout file must be loaded before using this window". We'll see in a later section what this is for.
You can see the file's properties in full:
Initially, the File Information window displays information held in the catalog.
If you specify the layout of the fields in a data file, the Data File Editor can provide a formatted display of the file's content. You create a record layout file from the Data Division of a COBOL program that uses the file. You must have compiled the program to create the necessary information.
Our data file DEMO.VSAM.DAT has three record types: employee, manager, and executive. You have to tell Data File Editor the layout of each type of record and how to identify the type. You define one type to be the default. The others are called conditional.
To create a record layout file:
Depending on your IDE options settings, you may have at the bottom of the IDE a list of the windows open in the IDE (similar in layout to the Windows taskbar). This is called the Workspace tabs. You can click the dtoldemo.mvp tab to bring the project window to the front. Otherwise, just click in the project window.
A Record Layout Editor window appears. The left-hand pane displays a tree view of the Data Division of DFDSTAFF.CBL. (The right-hand pane may be initially zero-width. If you can't see it, look at the right-hand edge of the window and if there's an extra vertical line there drag it to the left to make the right-hand pane visible. The pane is empty at the moment.)
To create the default record layout:
A folder for EMPLOYEE-REC-DEFAULT appears in the right-hand pane.
To create a conditional record layout:
As you have already defined a default layout, Conditional Layout is set automatically.
This adds MANAGER-REC as a conditional layout. A folder for MANAGER-REC appears in the right-hand pane.
You now need to specify the field and condition that identify the record type.
The Field Properties dialog box appears.
M indicates a Manager record type. The two characters below the dotted line are the hexadecimal equivalent, arranged vertically. They should be "D" and "4", since M in EBCDIC is hex D4.
A small red IF appears by 03 MN-POSITION in the right-hand pane.
To save the record layout file:
The Save As dialog box appears. The folder defaults to mfuser\projects\Gsdemo\Dtoldemo\Loadlib. The filename defaults to Layout. All record layout files use the .str extension.
In our case, we do not want these defaults. If you saved the file without changing the defaults, the record layout file would be saved as Layout.str in the directory Loadlib.
When loading a data file, the Data File Editor looks in the same folder for a record layout file with the same name as the data file and with extension .str. In a simple application where the data file has the same name as the COBOL program, apart from the extension, this default of the program name with .str extension is appropriate.
In the present case, however, you cannot simply change the name of the record layout file to match the data file, because the data file is cataloged with a mainframe-style name. Record layouts can only have PC-style names. So you have to tell Data File Editor that this record layout file is for use with this data file. We'll do this in a moment.
To use the record layout file:
A new right-hand pane appears, as shown in Figure 12-2. The data shown in the right-hand pane depends on which record is highlighted in the left-hand pane.
Figure 12-2: The Data File Editor Window with Record Layout Loaded
The left-hand pane contains the unformatted view of multiple records, one per line, that you had before.
In the right-hand pane, Data File Editor has applied the formatting information from the record layout file. This pane shows a formatted view of a single record. The record layout name is at the top of the pane. At the top right are two navigation controls:
You can edit a record by clicking in the Value column and typing over the existing data. The editing facilities mentioned earlier for the unformatted view are available in the formatted view too.
Notice how the formatted view alters, matching the record types as you move through the file.
Because our data file is catalogued, we can associate the loaded record layout file permanently with the data file.
In future, Data File Editor uses the record layout file automatically for our data file.
You can find out the record layout file associated with a data file and review the conditions that you set up for the different conditional layouts:
The File Information window opens. Because a record layout file is now associated with the data file DEMO.VSAM.DAT, the File Information window has a new tab Record Layouts.
This window displays information about the record layout file demolay.str that you associated with the file DEMO.VSAM.DAT. The top of the window displays the name and location of the record layout file.
The Conditions box underneath shows that, for Manager records, the field MN-POSITION equals M.
The Conditions box shows that, for Executive records, the field EX-POSITION equals E.
You can use Data File Editor to view and edit your data in hexadecimal:
New panes appear at the bottom of the window.
The left-hand pane shows the selected record from the top left-hand pane, with the hex beneath.
For elementary field items only, the right-hand pane shows the value in the selected field from the top right-hand pane, with the hex beneath. Otherwise, the right hand pane displays a text description such as Group item.
Each pair of hex digits is arranged vertically. For example, when you edit EBCDIC data, an M is shown in hex as "D" with a "4" beneath. If you can't see both lines of hex, make the window bigger by dragging its bottom edge downward.
The check mark by this menu item disappears, and the hex panes disappear.
From the Data File Editor, you can print out the contents of a data file. Alternatively, you might like to obtain a Print Preview that displays a copy of the printed output on screen.
Either way, you can choose the formatted or unformatted view. You can choose whether to print the current record, all records or partial records.
To preview a print of the unformatted view of a data file:
and select:
A Preview window appears. Use the buttons on the toolbar to zoom in and out and to move to another page. Use the scroll bars to move around the window.
As with many of the editors in Mainframe Express, you can use Data File Editor to edit several files at once. You can choose various ways to position the windows within the IDE.
To edit two data files, putting their windows one above the other:
A new Data File Editor window opens for DEMO.SEQ.DAT. Since no record layout is associated with this file, only the unformatted pane appears.
You can now see the Data File Editor windows for both DEMO.SEQ.DAT and DEMO.VSAM.DAT.
To create a fixed length sequential file:
The Allocate and create data set dialog box appears.
A Data File Editor window appears. The window displays "File empty".
If you go back to the project window and look at the Catalog View, you'll see that the new file has been automatically cataloged. If you cannot see the new file, click the Filter tab on the project window.
Let's add and delete a few records.
The cursor is positioned at the start of the file.
A copy of the above record is added to the file.
The new record is deleted from the file and the cursor is positioned on the previous record.
Close the project. If you want to take a break before going on to the next session, you can close Mainframe Express.
Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Running JCL on the Mainframe | Debugging COBOL |