|Overview of Working with Data Files||Using Record Layouts with Data Files|
This chapter describes the Data File Editor that Net Express provides for creating and editing data files on your PC.
For detailed information about using the Data File Editor, see the Net 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.)
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, Net 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.
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:
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.
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:
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 Ý and ß 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.
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:
The Layout Status Bar displays the name of the record layout in use for the current record.
The Field Layout View uses a COBOL record layout to display the field name, picture and value for each field in a record.
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 Ý and ß keys on your keyboard 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.
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:
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.
The status bar at the foot of the Net Express window displays the following information, from left to right:
The maximum and minimum record lengths as (min len to max len).
For sequential files only, the number of records in the file. (That is, the number of lines.) Non-sequential files are edited in place, so the number of records in the file is not known and "N/A" is displayed. For more information, see the section Navigating Non-Sequential Files.
The number of fields in the record.
The current position of the cursor, including: line number and column position. Both start at zero.
The number of the field currently selected.
Displays either "OVR" (for Overtype mode) or "Blank" (for Insert mode). You can toggle between these modes by pressing Insert.
This is empty. Numeric fields are always edited in overtype mode and alphanumeric fields are always edited in insert mode.
You can configure the Data File Editor by:
These three switches take effect the next time you open a data file in the current session. They do not take effect for any data files you have open currently.
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.
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.
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.
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:
Other processes can read the file and you cannot change any of the file's contents.
Only you can edit the data in the file.
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.
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.
To create a data file, click New on the File menu. On the New dialog box, click Data File and click OK.
Net Express opens the 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.
If you create indexed files, you need to define their keys. For more details, see the section Defining Keys for Indexed Files.
The following table shows the 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.|
Line sequential, fixed length sequential and fixed length relative files do not have file headers. Therefore, when you create one of these types of file, the Data File Editor offers to create a profile (.pro) file for storing the file header information. By default, the profile file is stored in the same folder as the data file and has the same file basename.
If you try to open a line sequential, fixed length sequential or fixed length relative file that has no profile file, the Data File Editor will prompt you for file header details.
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.
To allow access to files larger than 1 Gb, add FILEMAXSIZE=8 to the File Handler configuration file extfh.cfg. For more information about this file, see the chapter File Handler Configuration .
The locking behaviour of Data File Editor supports data files sized larger than one Gb with FILEMAXSIZE=4. This means that other programs cannot access a data file that is open for editing in Data File Editor. This does not apply if the Open read only field is selected in the Data Tools Options dialog box. If the data file is locked, Data File Editor prompts to try and open the file read only.
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.
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:
In addition, you can:
To open a data file, Net Express must be able to identify the file's type and record length. This information is stored either in the data file's header or in a profile file. For more information about header information, 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.
When you open a data file, Net Express uses the header information for the data file to identify the file's type and record length.
These file types contain header records that contain this information.
These file types do not contain file headers. Instead, the header information is kept separately in a profile (.pro) file. The profile file must have the same filename as the data file and must be in the same folder as the data file.
When header information is not available, Net 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 .
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:
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 Net 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.)
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:
Information about the data file, including location on disk, file organization, record format and record length
Information such as the number of records, the character set, whether the file was opened as read-only and whether you are using backup files
If the data file has a record layout file, information about the record layout in use for the current record. The top of the window displays the name and location of the record layout file. If you click on one of the records under Layout Name, you can view the condition set up for that type of layout.
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.
You can move through the file sequentially, as you would if you read the file sequentially using a COBOL program.
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 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.
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.
Use the left-hand pane of the Data File Editor window. To find out more, see the section Editing Data in the Left-Hand Pane.
Use the right-hand pane of the Data File Editor window. To find out more, see the section Editing Data in the Right-Hand Pane.
If you have hexadecimal values displayed, you can edit them directly. This enables you to type invalid data into your files for testing purposes.
For more information, see the section Initializing Data.
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.
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.
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.
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.
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.
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.
You can insert a new record either before or after the currently selected record.
You can also create new records by:
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:
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.
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.
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.
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.
You can print data from either the left-hand or right-hand pane. You can also preview the data.
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.
Printing or previewing from the formatted view is the same as for the unformatted view except:
Copyright © 2000 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||Using Record Layouts with Data Files|