Overview of Working with Data Files | Converting Data Files |
This chapter describes the Data File Editor which is the tool 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, click Development Environment, Working with Data Files, Editing.)
Use the Data File Editor to:
This is the unformatted view. Here you see several records at once, with one record per line. For further details on this view, see section Record View (Unformatted View).
This is the formatted view. Here you see records formatted into the fields used by your application. For further details on this view, see the section Field View (Formatted View).
To use this view, you have to create a record layout file that describes the record layout. You can use the record description in your application source code to create this file. For more information, see the chapter Using Record Layouts with Data Files.
The switches and warnings described below 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 Data Tools Settings in the chapter Overview of Working with Data Files.
The Data File Editor has two types of setting: switches and warnings.
You can control whether you:
When you open a file, the default is to take a backup automatically. If you make mistakes when editing the file, a backup protects you from losing data from the file. 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.
In read-only mode, other processes can read the file and you cannot change any of the file's contents.
In edit mode, only you can edit the data in the file. This is the default setting. However, if a file has the Windows read-only attribute, you cannot update the file.
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 field view. To find out more about record view and field view, see the section The Data File Editor Window.
Note: The above switches take effect the next time you open a data file in the current session. Therefore, when you change one of these settings, the new setting does not take effect for any data files you have open currently.
The following warnings and warning message are designed to help you avoid changing or deleting data inadvertently. When you:
Initially, warnings are switched on. You can switch off the warnings for the current session and all future sessions.The new setting for a warning takes effect when you next open a data file. Therefore, the new setting does not apply to any data files that are currently open.
Note: You can stop a message appearing again for the current session only by checking Do not show this message again on the warning message box.
You can use 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.
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-1: Allocate and Create Data Set Dialog Box
If the records are fixed length format, you specify the fixed length in Max length. If the records are variable length, you specify the maximum record length in Max length.
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 value under Min length, the 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.
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-2: Create File Dialog Box
If the records are fixed length format, you specify the fixed length in Max length. If the records are variable length, you specify the maximum record length in Max length.
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 value under Min length, the 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. |
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.
When you define keys for a mainframe-style file, you must:
In addition, you can:
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 file, you must:
In addition, you can:
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 Types and Record Lengths.
When Mainframe Express opens a file, the Data File Editor window opens. For more information, see the section The Data File Editor Window.
You can open a file as read-only to prevent accidental modification of the data. For more information, see the section Switches and Warnings.
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.
To find out a data file's header information, Mainframe Express looks first in the file header, if there is one. Then, Mainframe Express looks for a profile (.pro) file that holds the header information for the data file. If there is no profile file, Mainframe Express looks in the catalog.
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.
Note: .pro files are supported for migration only. You cannot create .pro files using Mainframe Express.
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:
Otherwise, the file is record sequential.
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, click Reference, COBOL Language Reference, Concepts of the COBOL Language, Selection of Character Representation and Radix, Overview - Selection of Character Representation and Radix.
The Data File Editor window opens when you create a new data file or open an existing data file.
The Data File Editor window is split into two panes:
The left-hand pane shows unformatted record data, with one record per line. For more information, see section Record View (Unformatted View)
The right-hand pane shows one record at a time of formatted data at field level. For more information, see section Field View (Formatted View).
Figure 11-3: Data File Editor Window
The left-hand pane shows unformatted record data, with one record per line. When you scroll left or right along a record, your view of all records on the screen scrolls at the same time.
You can select a record by either clicking a field or using + and -. The currently selected record is highlighted.
When the focus is on this pane, the status bar at the foot of the Mainframe Express window shows the following information, from left to right (see Figure 11-4):
For variable length records it also shows the maximum and minimum record lengths as (min len to max len). For fixed length records it shows (Fixed).
Non-sequential files are edited in place, so the number of records in the file is not known. For more information, see the section Viewing Non-sequential Files.
Figure 11-4: Relative File Record View and Status Bar
The right-hand pane shows formatted data at field level one record at a time. Each field is shown on a separate line. You can edit the contents of each field in the Value column.
To view and edit your data at field level, you need to create a record layout file. For further information, see the chapter Using Record Layouts with Data Files.
Use this view to display data at field level and to edit the contents of a field:
You can select a field by clicking on the field from either the Field Name or Format columns. Alternatively, use + and - from these two columns. The currently selected field is highlighted. To select the first field, press Home. To select the last field, press End.
To find a field quickly, use Data Tools > Locate Field on the Search menu.
You can edit the contents of a field by positioning the cursor in the column Value. To move the cursor to the beginning of the field, press Home. To move the cursor to the end of the field, press End.
To move between records, use the small up and down arrow buttons on the top right-hand pane of the field view window or select a new record in the record view pane.
When the field view pane is selected, the status bar at the foot of the Mainframe Express window shows the following information, from left to right (see Figure 11-5):
For variable length records it also shows the maximum and minimum record lengths as (min len to max len). For fixed length records it shows (Fixed).
Figure 11-5: Relative File Field View and Status Bar
With both views displayed, you can use either of the two methods below to keep the two views in step:
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, 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. To add a new conditional record layout, however, you must recreate the record layout file.
You can insert a new record either before or after the currently selected record.
You can also create new records by:
When you create a new record in a relative file, you have to provide a relative record number so that Data File Editor can position the new record in the file.
You can create a new record or copy an existing record.
Note: When you create a new relative record, the line number displayed in the status bar is reset to zero (see the section Viewing Non-sequential Files).
If you have not loaded any record layouts, Data File Editor uses the appropriate padding byte and sets the record to:
You can create a new record or copy an existing record.
Whenever you create or copy 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.
Note: When you create a new indexed record, the line number displayed in the status bar is reset to zero. See the section Viewing Non-sequential Files for more details.
You can only create a new record in a VSAM ES file (often known as ESDS files) 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 Viewing Non-sequential Files.
Once the record has been appended, you specify the field values in an editing session.
You can delete single or multiple records from any type of data file except for VSAM ES files.
The multiple delete procedure runs 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: You should ensure that Delete warning on the Data Tools check box is selected. For more details, see the section Switches and Warnings.
You can view the records in data files. For further details on this view, see the section Record View (Unformatted View).
If you have loaded a record layout, you can also view the fields used by your application. For further details on this view, see the section Field View (Formatted View).
You can look up the current Data file Editor settings for a file, as well as view mainframe-style and PC-style file details.
To look up this information, click Data Tools>File Information on the View menu. Alternatively, right-click in the Data File Editor window and click File Information on the popup menu.
Data File Editor displays all data as either ANSI or EBCDIC. You can alternate between these character sets using the Data File Toolbar (see Figure 11-6). This toolbar shows you which character set and selected key are currently in use.
To display the Data File Toolbar, click Dockable Windows from the View menu, check the Data File Toolbar and click OK.
Figure 11-6: Data File Toolbar
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.
By default, 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 (see Figure 11-6). This shows the currently selected key and character set.
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 status bar at the foot of the Mainframe Express window will be 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.
You can:
Notes:
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.
There are several ways of moving to a particular record for editing:
In addition, if a record layout is associated with the data file, you can jump directly to a field within a record. See the section Searching a File for more details.
You can edit data in record view by overtyping, inserting or deleting data. To find out more about record view, see the section Record View (Unformatted View).
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, check Always overtype in unformatted view on the Data Tools checkbox.
If Update warning is selected, you see an Update warning message box.
For more information about these settings, see the section Switches and Warnings.
You can edit alphanumeric or numeric data directly in any field.
Modes enabled for editing are:
Numeric fields are enabled only to accept numeric data.
When you delete numeric characters, each digit is set to zero.
You can only insert new characters 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.
If Update warning is checked, you see an Update warning message box. For more information, see the section Switches and Warnings.
Notes:
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.
You can change the length of a record in a variable length file. If you reduce the length of a record, the record is truncated to the new length. If you increase the length of a record, the extra bytes are filled with the current padding byte.
This section describes how to view and edit in hexadecimal.
You can display your ANSI or EBCDIC data in hexadecimal by clicking Data Tools>Show Hex on the View menu. The hexadecimal value of each byte is displayed in a window below the main edit window. For both record and field level displays, each character has its hexadecimal representation on the two lines below.
Figure 11-7 shows a file with hexadecimal display.
If you have hexadecimal values displayed, you can edit them directly. This enables you to type invalid data into your files for testing purposes.
To display your ANSI or EBCDIC data in hexadecimal, click Data Tools>Show Hex on the View menu.
The hexadecimal value of each byte is displayed in a window below the main edit window. Each character has its hexadecimal representation on the two lines below it for both record and field level displays. You can edit both the character and the individual hexadecimal values.
Figure 11-7 shows a file with hexadecimal display.
Figure 11-7: File with Hexadecimal Display
The Data Tools option on the Search menu offers the following types of search:
You can search a data file to find a particular string.
Additionally, you can search your file for a particular string and replace it with another specified string. You can:
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. Depending on whether the Data File Editor window is open and, if so, the current key of reference, this option name can also read as Find on prime key and Find on alternate key number n.
You can find a record to edit.
From field view, you can locate a field within a record to edit. For further details on this view, see the section Field View (Formatted View).
If you have a record layout file loaded or associated with this file, you see the results of your search highlighted in the right-hand pane of the edit window. For more details, see the chapter Using Record Layouts with Data Files.
When you use any type of search, Data File Editor selects the first record it finds in your chosen search direction which matches your search criteria.
If there are no matches, the message "Could not find search string after the current edit position" is displayed.
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.
You can print your data file records either unformatted or formatted. You can also preview the data.
If you have not loaded a record layout file, you can only print or preview your data in the unformatted view. For more details, see the chapter Using Record Layouts with Data Files.
If you are printing or previewing from the unformatted view, you can print:
If you are previewing records, you can change the magnification of the display.
Notes:
Printing or previewing from the formatted view is the same as for the unformatted view except:
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Overview of Working with Data Files | Converting Data Files |