PreviousRunning JCL on the Mainframe Debugging COBOLNext"

Chapter 12: Maintaining and Creating Data Files

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.

12.1 Overview

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:

In this session, you:

12.2 Preparation

To save you creating the project used in this session, we supply the project dtoldemo.mvp.

  1. If you have closed Mainframe Express, open it as before. If any project window or other windows are open, close them.

  2. Click Open Project on the File menu and open \mfuser\projects\Gsdemo\Dtoldemo\Dtoldemo.mvp.

  3. If Catalog is not already selected, click the Catalog tab to open the Catalog View.

    You'll see the demo data file DEMO.SEQ.DAT.

12.3 Sample Session

In this session you:

12.3.1 Converting a File

To make a VSAM copy of the supplied sequential file:

  1. In the Catalog View, select DEMO.SEQ.DAT.

  2. Click Data Tools on the Tools menu, then click Convert DEMO.SEQ.DAT.

    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.

  3. In the lower part of the dialog box, enter the following details for the output file:


  4. Leave the remaining fields unchanged and click Validate.

  5. A message informs you that a description for the selected output data set is to be added to the catalog. Click OK.

    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.

  6. Click Define Keys. Then click Insert Key.

    The field to be used as the primary key is at the beginning of the record, and is seven bytes long.

  7. Set Key Offset to 0 and Key Length to 7. Then click OK.

  8. Click Convert.

  9. Click OK on the message saying the conversion is complete.

  10. A message box gives the results of the conversion. Click Close.

    If you wanted to convert more files, you could have clicked OK instead to return to the Dataset Convert dialog box.

  11. An entry for the new file DEMO.VSAM.DAT is now in the catalog. If you cannot see the file, ensure the Filter field contains an asterisk, and click Filter.

12.3.2 Viewing a Data File Unformatted

To view the file you just created:

  1. In the Catalog View, right-click DEMO.VSAM.DAT. Then click Edit on the popup menu.

    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.

  2. A message box explains that your edits to indexed and relative file types are applied immediately. You can stop this message appearing again for the current session by checking Do not show this message again. (To stop the message permanently, you can uncheck the Data Tools setting Show please note message. For more information, see your User's Guide.)

  3. Click OK.

    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 g           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:

  1. Right-click in the Data File Editor window and, on the popup menu, click File Information.

    Initially, the File Information window displays information held in the catalog.

  2. To view more information about the file, such as file format, organization and keys, click in turn the PC File, Keys and General tabs.

  3. When you have finished, click Cancel to close the File Information window.

  4. Leave the Data File Editor window open to use later in this tutorial.

12.3.3 Creating a Record Layout File

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:

  1. Bring the project window to the front.

    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.

  2. Click the Files tab on the project window.

  3. Right-click DFDSTAFF.CBL and click Compile DFDSTAFF.CBL.

  4. Right-click DFDSTAFF.CBL again and click Create Record Layout.

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

12.3.4 Creating the Default Record Layout

To create the default record layout:

  1. Expand the FD MF-FILE entry by clicking its "+".

  2. Right-click 01 EMPLOYEE-REC and then click New Record Layout on the popup menu.

  3. To set EMPLOYEE-REC as the default record layout, ensure Default Layout is selected and click Next.

  4. Click Finish.

    A folder for EMPLOYEE-REC-DEFAULT appears in the right-hand pane.

12.3.5 Creating the Conditional Record Layouts

To create a conditional record layout:

  1. Right-click 01 MANAGER-REC. Then click New Record Layout on the popup menu.

    As you have already defined a default layout, Conditional Layout is set automatically.

  2. Click Next. Then click Finish.

    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.

  3. In the right-hand pane, expand the MANAGER-REC folder by clicking its "+", then expand the 01 MANAGER-REC entry by clicking its "+" and then expand the 02 MN-CODE entry by clicking its "+".

  4. In the right-hand pane, right-click 03 MN-POSITION. Then click Properties on the popup menu.

    The Field Properties dialog box appears.

  5. Select the Condition IS = TO from the pulldown list.

  6. Type M (upper case) in the left-hand Condition field.

    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.

  7. Click OK.

    A small red IF appears by 03 MN-POSITION in the right-hand pane.

  8. Create a conditional record layout for the Executive record type, by repeating this section replacing MANAGER by EXECUTIVE, MN-POSITION by EX-POSITION, and M by E.

12.3.6 Saving the Record Layout File

To save the record layout file:

  1. Click Save on the File menu.

    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.

  2. Change the folder to \mfuser\projects\gsdemo\dtoldemo\data by clicking g           and then double-clicking Data.

  3. Change the File Name field for the record layout file to demolay. Then click Save.

  4. Close the Record Layout Editor window, by either clicking Close on the File menu or clicking the window's g           button.

12.3.7 Viewing a Data File Formatted

To use the record layout file:

  1. To return to the Data File Editor window that you left open earlier, either click in it or click the DEMO.VSAM.DAT (VSAM KS) tab.

  2. Click Load Record Layouts on the File menu.

  3. Select demolay.str and click Open.

    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.

  4. Click in the left-hand pane, and move the cursor over the records in the unformatted view

    Notice how the formatted view alters, matching the record types as you move through the file.

12.3.8 Associating a Record Layout File

Because our data file is catalogued, we can associate the loaded record layout file permanently with the data file.

  1. Ensure that the Data File Editor window is at the front, and that the formatted view is still displayed (so the record layout file is still loaded).

  2. From the File menu, click Associate Record Layouts.

  3. To save the association, click Yes.

  4. Click OK.

In future, Data File Editor uses the record layout file automatically for our data file.

12.3.9 Looking Up Information about a Record Layout 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:

  1. Right-click in the Data File Editor window. Then click File Information on the popup menu.

    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.

  2. Click the Record Layouts tab.

    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.

  3. Under Layout Name, click on MANAGER-REC.

    The Conditions box underneath shows that, for Manager records, the field MN-POSITION equals M.

  4. Under Layout Name, click on EXECUTIVE-REC.

    The Conditions box shows that, for Executive records, the field EX-POSITION equals E.

  5. Click Cancel to close the File Information window.

12.3.10 Viewing Files in Hexadecimal

You can use Data File Editor to view and edit your data in hexadecimal:

  1. Right-click within either pane of the Data File Editor window and click Show Hex on the popup menu.

    New panes appear at the bottom of the window.

    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.

  2. Right-click within the Data File Editor window and click Show Hex on the popup menu.

    The check mark by this menu item disappears, and the hex panes disappear.

12.3.11 Printing a Data File

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:

  1. Click in the left-hand pane of the Data File Editor window. Then click Print Setup on the File menu.

  2. Set Orientation to Landscape and click OK.

  3. Click Print Preview on the File menu.

  4. Click Header (text) and specify the heading text as Print of DEMO.VSAM.DAT.

  5. Put check marks by:

    and select:

  6. Click Preview.

    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.

  7. Click Print on the toolbar of the Preview window. Then click Print on the Print dialog box.

12.3.12 Editing Multiple Data Files

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:

  1. Make sure that the Data File Editor window for DEMO.VSAM.DAT is still open.

  2. Click the Dtoldemo.mvp tab to return to the project window.

  3. Click the Catalog tab on the project window.

  4. From the project window, right-click DEMO.SEQ.DAT. Click Edit on the popup menu.

    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.

  5. Minimize the project window by clicking the g           button on the window.

  6. Select Tile Horizontally on the Windows menu.

    You can now see the Data File Editor windows for both DEMO.SEQ.DAT and DEMO.VSAM.DAT.

  7. Toggle between the windows by clicking alternately on the tabs for DEMO.SEQ.DAT and DEMO.VSAM.DAT.

  8. Close both Data File Editor windows. Restore the project window to its normal size by clicking its g           button.

12.3.13 Creating a New Data File

To create a fixed length sequential file:

  1. Select New on the File menu. Select Data File and click OK.

    The Allocate and create data set dialog box appears.

  2. Specify NEW.FILE in the DS Name field, and 20 in the Max Length field.

  3. Accept the defaults for the other fields, and click Create.

    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.

  4. Right-click in the Data File Editor window for NEW.FILE. Then click Insert Record After on the popup menu.

    The cursor is positioned at the start of the file.

  5. Type abc.

  6. Right-click in the Data File Editor window. Then click Repeat Record on the popup menu.

    A copy of the above record is added to the file.

  7. Right-click in the Data File Editor window. Then click Delete Record on the popup menu.

  8. Click Yes on the Delete warning message box..

    The new record is deleted from the file and the cursor is positioned on the previous record.

  9. Click Save on the File menu.

  10. Close the Data File Editor window.

12.4 Before Continuing

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.

PreviousRunning JCL on the Mainframe Debugging COBOLNext"