Chapter 11: Editing Data Files

This chapter describes the Data File Editor that Mainframe Express provides for creating and editing data files on your PC.

For detailed information about using the Data File Editor, see the Mainframe Express online help. (Click Help Topics on the Help menu. Then, on the Contents tab, double-click Development Environment, Working with Data Files, Editing Data Files.)

11.1 Overview

The Data File Editor provides a graphical interface for editing data files. You can:


Note: To view and edit formatted data, you must first of all define record layouts for your data files. For this purpose, Mainframe Express provides a Record Layout Editor. To find out more about the Record Layout Editor, see the chapter Using Record Layouts with Data Files.


The rest of this chapter assumes that you have record layouts loaded to format your data.

11.2 The Data File Editor Window

The Data File Editor opens when you create a new data file or open an existing data file. The Data File Editor has one main window:



Figure 11-1: Data File Editor Window

This window is divided into left-hand pane and a right-hand pane. At the bottom of the window, there is the Data File status bar. Above the window is the Data File toolbar.

You can view and edit data in hexadecimal in both the left-hand and right-hand panes. The hexadecimal value of each byte is displayed on two lines below each pane.


Note: If you have not yet defined any record layouts for the data file, the right-hand pane does not display any data. For more information about record layouts, see the chapter Using Record Layouts with Data Files.

Tip: By right-clicking in the Data File Editor window, you can display a context sensitive popup menu with a small subset of menu options. For example, you can insert and delete records.


11.2.1 Left-Hand Pane

The left-hand pane of the Data File Editor window is also referred to as the unformatted view. The left-hand pane shows record data, with one record per line:

Ushort descr

Figure 11-2: Unformatted Record Data in the Left-Hand Pane

In the left-hand pane, the key areas in an indexed file are highlighted in red.

To scroll through a record, you can use the horizontal scroll bar. To scroll up and down records, you can use the cursor-up and cursor-down keys on your keyboard. The record that is currently highlighted is the current record and is available for editing. You can also click a record to select a record for editing.

If any of the records either does not match any of the available record layouts or contains an invalid OCCURS DEPENDING ON RANGE, the right-hand pane and Data File status bar display a warning message.


Tip: When you position the cursor in a record, you can force the cursor to the same position in the right-hand pane by clicking DataTools > Synchronize Views on the View menu.


11.2.2 Right-Hand Pane

The right-hand pane of the Data File Editor window is also referred to as the formatted view. The right-hand pane is empty unless there is a record layout associated with the current record. For more information about record layouts, see the chapter Using Record Layouts with Data Files.

From the top down, the right-hand pane displays the following areas:

Ushort descr

Figure 11-3: The Field Layout View in the Right-Hand Pane

To select the Field Layout View, click inside the right-hand pane. You can resize the columns by dragging the column dividers on the column headings row.

Each field is shown on a separate line. You can use the cursor-up and curosr-down keys to scroll up and down the fields. To select the first field, press Home. To select the last field, press End. The currently selected field is highlighted.

You can edit the contents of a field by positioning the cursor in the Value column. To move the cursor to the beginning of the field, press Home. To move the cursor to the end of the field, press End.


Tips:


11.2.3 The Data File Toolbar

Use the Data File toolbar as a short-cut when you want to change character set, select a different key of reference for an indexed file or look up information about a data file:



Figure 11-4: The Data File Toolbar

The Data File Editor displays all data as either ANSI or EBCDIC. The Data File toolbar shows you which character set is currently in use. You can tell if your file is being displayed in the wrong format by looking for spaces in display format information. If you display an EBCDIC format file in ANSI, spaces (EBCDIC code h"40") appear as "@". If you display an ANSI file in EBCDIC, spaces (ANSI code h"20") appear as non-alphanumeric characters - the exact character depends on the operating system character set.

You can switch the Data File toolbar on and off by clicking Dockable Windows on the View menu.

11.2.4 The Data File Status Bar

The status bar at the foot of the Mainframe Express window displays the following information, from left to right:

11.3 Configuring the Data File Editor

You can configure the Data File Editor by:

To change these configurations, click Data Tools on the Options menu and then click the Data File Editor tab on the Data Tools Options dialog box.


Note: The switches and warnings described here apply specifically to the Data File Editor. There are other settings that you can change for the Data Tools in general. For more information, see the section Configuring the Data Tools in the chapter Overview of Working with Data Files.


11.3.1 Switching Off Warning Prompts

Before using the Data File Editor, you might like to consider whether you want to be prompted every time you attempt to edit or delete a record. For both operations, by default, the Data File Editor displays a prompt asking you if you want to continue. By deselecting the Update Warning and Delete Warning fields in the Data Tools Options dialog box, you specify that the Data File Editor does not display these prompts.

The Data File Editor prompts you each time you open either an indexed or a relative file, since edits to both of these file types are applied immediately. For sequential files, you are prompted when you attempt to edit the data. You can deselect the Show Please Note Message field to specify that you do not require these prompts.

Any changes that you make to these settings take effect when you next open a data file. If you do switch either of the prompts on or off, make sure that you inform anyone else who uses the Data File Editor on your PC.


Note: You can stop a warning message appearing again for the current session by checking Do not show this message again on the warning message box.


11.3.2 Obtaining Back Ups

In the Data Tools Options dialog box, the Back up file before editing field controls whether the Data File Editor makes a back up of each data file that you open. By default, the editor takes a backup automatically. You can use the backup to restore the file to the state it was in before you made your edits.

Backup files are kept in the same folder as the data file. Your data file is copied to filename.dbk. If the data file is indexed, the index is copied to filename.ibk.

11.3.3 Opening Data Files as Read-Only

In the Data Tools Options dialog box, the Open read only field controls whether you can open data files in read-only mode or edit mode:

By default, the Data File Editor uses edit mode. However, even with edit mode selected, you cannot edit a file that has the Windows read-only attribute.

11.3.4 Editing in Insert or Overtype Mode

In the Data Tools Options dialog box, the Always overtype in unformatted view field controls whether Insert or Overtype mode is the default editing mode in the left-hand pane of the Data File Editor window. By default, the editing mode is Overtype mode.

Inserting or deleting data can result in a shift of all your data fields. To avoid such possible problems, always use the overtype mode. If you press Insert while in overtype mode, a message box asks you to confirm that you really do want to switch to insert mode.

This setting has no effect in the right-hand pane, where you always edit numeric fields in overtype mode and alphanumeric fields in insert mode.

11.4 Creating a Data File

You can use the Data File Editor to create both mainframe-style and PC-style data files.

If you create indexed files, you need to define their keys. For more details, see the section Defining Keys for Indexed Files.

11.4.1 Creating a Mainframe-style Data File

A mainframe-style file is also known as a data set. This type of file is a cataloged file and belongs to a project.

Before creating a mainframe-style file, therefore, you must click Data Tools on the Options menu, check Use catalog and click OK. Then, you must open the project that is going to contain the file.

Then, to create the file, open the Catalog View. From the File menu, click New. From the New dialog box, select Data file and click OK. Mainframe Express displays the Allocate and create data set dialog box:



Figure 11-5: Allocate and Create Data Set Dialog Box

If the records are fixed length format, you specify the fixed length in the Max length field. If the records are variable length, you specify the minimum and maximum record lengths in the Min length and Max length fields.

Once you have created the file, Mainframe Express adds its details to the catalog dynamically.

The following table shows the file types, organizations and record formats available for mainframe-style files. The table shows whether or not you have to define keys and/or specify a minimum record length. The minimum record length applies to variable record formats only.

File organization (DSORG) Record format (RCFM) Define keys? Specify minimum length?
DA, DAU F, FB, FBS, FS, LSEQ, V, VB, VBS, VS No Yes if record format is one of the variable types
PS, PSU F, FB, FBS, FS, LSEQ, V, VB, VBS, VS No Yes if record format is one of the variable types
IS, ISU F, FB, FBS, FS, V, VB, VBS, VS Yes Yes if record format is one of the variable types. The minimum length must exceed the largest offset plus key length combination defined for this file.
VSAM KS Yes The minimum length must exceed the largest offset plus key length combination defined for this file.
VSAM RR No Yes
VSAM ES Optional If the file has keys, the minimum length must exceed the largest offset plus key length combination defined for this file. For files without keys it may be zero.

For definitions of these data set organization and record format codes, see the chapter Advanced Data Set Information in your IDE Technical Guide.

11.4.2 Creating a PC-style Data File

To create a PC-style file, you must click Data Tools on the Options menu, uncheck Use catalog and click OK. Then, click New on the File menu. On the New dialog box, click Data File and click OK.

Mainframe Express opens the Create file dialog box:



Figure 11-6: Create File Dialog Box

If the records are fixed length format, you specify the fixed length in the Maximum length field. If the records are variable length, you specify the minimum and maximum record lengths in the Minimum length and Maximum length fields.

The following table shows the PC file and record formats available. The table shows whether or not you have to define keys and/or specify a minimum record length. The minimum record length applies to variable record formats only.

File format Record format Define keys? Specify minimum length?
Micro Focus Sequential Fixed, Variable No Yes if record format is variable.
Micro Focus Line Sequential Variable No No.
Micro Focus Indexed Fixed, Variable Yes Yes if record format is variable. The minimum length must exceed the largest offset plus key length combination defined for this file.
Micro Focus Relative Fixed, Variable No Yes if record format is variable.
IDXFORMAT(4) Fixed, Variable Yes Yes if record format is variable. The minimum length must exceed the largest offset plus key length combination defined for this file.
IDXFORMAT (8) Fixed, Variable Yes Yes if record format is variable. The minimum length must exceed the largest offset plus key length combination defined for this file.

11.4.3 IDXFORMAT(8) Data Files

The Data Tools support indexed files larger than 2 Gb on operating systems such as Windows NT that can deal with such huge files. The format to use for such files is IDXFORMAT(8).

Unlike other indexed files, an IDXFORMAT(8) file does not hold its index in a separate file. Instead, each IDXFORMAT(8) file holds both the data and the index information.

File support is limited to data files with up to approximately 2.1 billion records. When opening a sequential data file in Data File Editor, 25 bytes of virtual memory per sequential record are needed, so the limit is less.


Warnings:


11.4.4 Defining Keys for Indexed Files

If you are creating an indexed file, the Define Keys button enables. When you click Define Keys, you can use the Key Information dialog box to enter information about keys. This information is different for mainframe-style and PC-style files.

11.4.4.1 Defining Keys for Mainframe-style Files

When you define keys for a mainframe-style file, you must:

In addition, you can:

11.4.4.2 Defining Keys for PC-style Files

Keys for PC-style files contain components. You specify the offsets and lengths of the components rather than of the keys. You can manipulate keys and their components too.

When you define keys for a PC-style file, you must:

In addition, you can:

11.5 Opening a Data File

To open a file, click Open on the File menu. For a mainframe-style file, you can also double-click the file in the Catalog View.

To open a file, Mainframe Express must be able to identify the file's type and record length. Indexed, variable-length sequential and variable-length relative files have header records that contain this information. If the file is cataloged, the information is also in the catalog. For more information about file headers, see the section File Headers.

When you open a sequential file, Data File Editor loads the file into memory which is where you modify the data. The data file is not updated on disk until you close the file. A message asks if you want to apply the changes that you have made.

When you open an indexed or relative file, the file is not loaded into memory because these types of files can be very large. When you modify data in one of these file types and then move off the record, Data File Editor updates the record on disk and displays a message box to confirm.


Notes:


11.5.1 File Headers

When you open a data file, Mainframe Express uses the header information for the data file to identify the file's type and record length.

If none of these sources provides the file type and record length, Mainframe Express prompts you for the file type and record length. You can find out a file's file type and record length by inspecting the source code. For help on identifying the file type and record length, see the sections Identifying a File Type and Identifying a Record Length .

11.5.2 Identifying a File Type

To identify line sequential, fixed length sequential and fixed length relative files, look under the Input-Output Section at the ORGANIZATION phrase of the SELECT statement:


Notes:


11.5.3 Identifying a Record Length

To find the record length, look at the record layout described by the FD entry in the File Section. The record length is the sum of all the lengths of all the elementary data items which make up the FD group item.

Each character position occupies one byte for PIC X and PIC 9 items. To find out how to calculate the length of computational fields (COMP-1, COMP-2, COMP-3, COMP-4, COMP-5 and COMP-X), consult the Mainframe Express online help. (Click Help Topics on the Help menu. Then, on the Contents tab, double-click Reference, COBOL Language Reference, Concepts of the COBOL Language, Selection of Character Representation and Radix, Overview - Selection of Character Representation and Radix.)

11.6 Obtaining Information about a Data File

You can click on the Data File toolbar and then click one of the following tabs to find out more about the data file that is open:

11.7 Navigating a Data File

For all types of data file, you can jump directly to a particular position in a file by defining a line number and a column number, both of which start at zero. If the current record has a record layout, you can also jump directly to a field.

You can search for a particular record or string. See the section Searching a Data File for more details.

To find out how to navigate the Data File Editor window, see the section The Data File Editor Window

11.7.1 Navigating Sequential Files

You can move through the file sequentially, as you would if you read the file sequentially using a COBOL program.

11.7.2 Navigating Non-Sequential Files

You can alter your position in a file by:

When you change your position in a file in one of these ways, the line number that you see in the Data File status bar is reset to zero. This is because line numbers in these types of files can only be determined with respect to some given position.

The line number then changes as you move through the file:

To maintain consistency with the line number, the column number also starts from zero.

11.7.3 Changing the Key in an Indexed File

By default, the Data File Editor displays records in an indexed file in primary key order. If the file has alternate keys, you can change the display order by selecting a different key of reference. To select an alternate key for viewing an indexed file, use the Data File toolbar which shows the currently selected key and character set.

11.8 Editing a Data File

You can:

11.8.1 Editing Data in the Left-Hand Pane

When you insert or delete data in record view, you can create a shift in all of your data. Therefore, to avoid corrupting the fields following the insert or delete, make sure that the Always overtype in unformatted view field on the Data Tools Options dialog box is selected. For more information, see the section Editing in Insert or Overtype Mode.

To see your edits reproduced in the right-hand pane, click DataTools > Refresh Formatted Pane on the View menu.

11.8.2 Editing Data in the Right-Hand Pane

In the right-hand pane, you always edit numeric fields in overtype mode and alphanumeric fields in insert mode.

Numeric fields can accept numeric data only. When you delete numeric characters, each digit is set to zero.

You can only insert new characters into an alphanumeric field if the field has space for them. For example, if a PIC X(4) field already has four characters in the field, you must delete these and replace them with the new data. When you delete alphanumeric characters, spaces are added to the right-hand edge of the field.

A field containing invalid data is displayed as asterisks (*). If you select such a field, a message box displays and asks if you want to initialize the field.


Warning: If you are editing an indexed file, you must take care with changes to key values:


11.8.3 Initializing Data

You can initialize a single field or all the fields in a record:

If you have created any conditional record layouts, the field used for testing the condition remains unaffected by initializing a record. (For information about conditional record layouts, see the section Types of Record Layout in the chapter Using Record Layouts with Data Files.)

If the file is indexed, the keys for a record remain unaffected by initializing a record.

11.8.4 Restoring Data

When you select a record, the Data File Editor saves the data in case you want to undo any edits you make to the record. While the record that you edit remains the current record, you can use Data Tools > Undo Record Edit on the Edit menu to restore the saved data for that record.

If you have the Back up file before editing field selected in the Data Tools Options dialog box, you can restore the whole file from a backup (see the section Obtaining Back Ups). The backup file has the same basename as the data file with the extension .dbk. To retrieve the backup, you should close the editing window. Then, you can use a file manipulation tool such as Explorer to copy the backup .dbk file over your .dat file.

If the file is indexed, a separate index file holds the index. This index file has the same basename as the data file with the extension .idx. The backup file for the index has the same basename as the data file with the extension .ibk. To make sure that the index and data keep in step, you must also copy the backup .ibk file over your .idx file.

11.9 Adding and Deleting Records

The methods for creating records are different for sequential, relative and indexed files: sequential files do not have keys; relative and indexed files have different types of keys. Special considerations apply to VSAM ES files.

If you have a record layout file loaded, you can choose to base a new record on one of the record layout types or have the new record filled with padding bytes. For more information about record layouts, see the chapter Using Record Layouts with Data Files. If you have created conditional record layouts and you choose your new record to be one of these, the condition field is set appropriately.

11.9.1 Adding Records to a Sequential File

You can insert a new record either before or after the currently selected record.

You can also create new records by:

11.9.2 Adding Records to a Relative File

You can add a new record to a relative file by either creating a new record or copying an existing record.

When you add a new record, you have to provide a relative record number so that Data File Editor can position the new record in the file. The line number displayed in the Data File status bar is reset to zero (see the section Navigating Non-Sequential Files).

If you have not loaded any record layouts, Data File Editor uses the appropriate padding byte and sets the record to:

11.9.3 Adding Records to an Indexed File

You can add a new record to an indexed file by either creating a new record or copying an existing record. The line number displayed in the Data File status bar is reset to zero (see the section Navigating Non-Sequential Files).

Whenever you add an indexed file record, you specify all unique keys for the new record. The prime key should always be a unique key. In some cases, a file might also have one or more unique alternate keys.

If you are inserting records with record layouts loaded, any key information that you specify during the insert process takes precedence over conditional data associated with the selected record layout. For more information about record layouts, see the chapter Using Record Layouts with Data Files.

11.9.4 Adding Records to a VSAM ES File

You can only create a new record in a VSAM ES file (often known as an ESDS file) by appending an empty record to the end of the file. If the file has alternate indexes, you must also supply any unique key values.

The new record is always positioned physically at the end of the file. If the file has alternate indexes, the empty record appears in the editing window in the position in the file dictated by the key of reference. For more details, see the section Navigating Non-Sequential Files.

Once the record has been appended, you specify the field values in an editing session.

11.9.5 Deleting Records

You can delete single or multiple records from any type of data file except for VSAM ES files.

A multiple delete continues to run even if insufficient records are available. The delete continues until the end of the file when a message box displays the number of records deleted.


Note: To help avoid accidental deletion, you should ensure that Delete warning on the Data Tools Options dialog box is selected. For more details, see the section Switching Off Warning Prompts.


11.10 Searching a Data File

You can use the search option to look for a particular string in a data file. You can search forwards or backwards through the data file.

Additionally, you can search your file for a particular string and replace it with another specified string. If you enter a replace string that is shorter than the search string, the Data File Editor fills the empty bytes with padding characters. Replace strings longer than the search string are truncated. This is a way of preserving the consistency of field positions within the record.

For indexed files only, you can search on the current key of reference.


Note: When you are searching on a numeric key with COMPUTATIONAL usage, you must specify the hexadecimal value. Data File Editor does not format data specified in the Find on Key dialog box, even where a record layout file exists. This is because a key can be split across several fields which might each have different formatting.


11.11 Printing a Data File

You can print data from either the left-hand or right-hand pane. You can also preview the data.

11.11.1 Printing Records from the Left-Hand Pane

If you are printing or previewing records from the left-hand view, you can choose to print:

When you display a print preview, the Data File status bar shows the page number. You can change the magnification of the display.


Warning. The available memory limits the size of the print preview possible. If memory is exhausted while preparing a print preview memory, you see an error. There is no such limitation on printing files.


11.11.2 Printing Field Data from the Right-hand Pane

Printing or previewing from the formatted view is the same as for the unformatted view except:


Copyright © 2001 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.