File Conversion Utilities |
This chapter describes the facilities NetExpress provides to help you create and maintain your application's data files on your PC.
NetExpress offers the following GUI data tools to help you create, maintain and convert data files:
Create, edit and print data files of various types.
Convert data files from one format to another
Create and maintain record layouts. Record layouts enable both the Data File Editor and the Data File Converter to operate at the individual field level.
Rebuild the index of a corrupt indexed file.
For an introduction to using these Data Tools, we recommend you work through the chapter Maintaining and Creating Data Files in your Getting Started.
For detailed information about using the facilities described in this chapter, see the help provided in the NetExpress online help file. (Click on the Help Topics button, ensure that the Contents tab is at the front and then select Development Environment, Data Tools.)
When you open a file, NetExpress 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.
Line sequential, fixed length sequential and fixed length relative files do not have file headers. To save you having to enter the file type and record length each time you open the file, you can save this information in a profile file in the same directory as the data file. The profile file has the same filename as the data file and a .pro extension.
When you open a line sequential, fixed length sequential or fixed length relative file, NetExpress looks in the same directory for a .pro file with the same filename as the datafile. If there is no .pro file, NetExpress 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. After you have entered these file header details, Net Express prompts you to save the details to a profile file.
To identify line sequential, fixed length sequential and fixed length relative files you need to look in the Input-Output Section, at the ORGANIZATION phrase of the SELECT statement.
Notes:
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 topic Overview - Selection of Character Representation and Radix in the COBOL Language Reference section of the online help for more details.
You can modify the behavior of the Data Tools by changing the Data Tools settings. These settings take effect until the next time you change them. To change or view the settings, select Data Tools from the Options menu.
Many of these settings are concerned with protecting you from the results of inadvertently changing or deleting your data. The settings are as follows:
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 directory 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.
You can set Data File Editor to open files as:
Other processes can read the file; you can't change any of the file's contents.
This is referred to as edit mode: you can edit your data in the file; other software cannot access your file. This is the default setting.
If a file has the DOS read-only attribute, you cannot update the file whether or not Data File Editor is set to open files read-only.
When you edit data, Data File Editor displays a warning message by default. You can turn the warning off for all sessions or for the current session only.
When you delete a record, Data File Editor displays a warning message by default. You can turn the warning off for all sessions or for the current session only.
Inserting or deleting data can result in a shift of all your data fields. To avoid possible insert edit problems, always use the overtype mode.
If you press Insert while in overtype mode, you are asked if you would like to switch to insert mode.
This setting has no effect in the formatted view (see the section Field View (Formatted View)).
You use padding bytes when you insert or create records. The padding byte that Data File Editor uses depends on the character set in use. For example, you can choose nulls or spaces to pad records. You can select a different padding byte for EBCDIC and for ANSI.
The Data Tools need to know the character set used in your data files. You should set the default character set to the one you use most often. While you are editing a particular file, you can toggle between the two character sets that are available, EBCDIC and ANSI.
Using the Codecomp utility, you can create customized mapping tables for EBCDIC/ANSI character set translation. NetExpress has built-in support for a number of character sets. For more information, see the help provided in the NetExpress online help file. (Click on the Help Topics button, ensure that the Contents tab is at the front and then select Development Environment, Data Tools, Configurable Codesets.)
You can use Data File Editor to create data files.
If you create indexed files, you will need to define their keys (see the section Defining Keys).
Once your files exist, you can open a file for editing.
To create a data file, select New on the File menu then Data File in the New dialog box. The Create file dialog box is shown.
Figure 12-1: Create File Dialog Box
Use Maximum length according to the format of the records as shown below:
Specify the fixed length.
Specify the maximum record length.
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 in the Create File dialog box or Data File Convert dialog box becomes enabled. When you click Define Keys, you see the Key Information dialog box.
Keys for data files contain components, and you specify the offsets and lengths of the components rather than of the keys. You can manipulate both keys and components of keys.
When you define keys for a data file, you must:
In addition, you can:
When you open a sequential file, Data File Editor loads the file into memory where you modify the data. The data file isn't updated on disk until you close the file and you see a message asking if you want the changes that you have made to be applied.
When you open an indexed or relative file, the file isn't loaded into memory because these types of files can be very large. When you modify data in one of these file types, then move off the record, Data File Editor updates the record on disk and displays a message to that effect.
The Data File Editor gives you the option of opening a file as read-only to prevent accidental modification of the data (see the section Data Tools Settings).
You can open a file using Open on the File menu. When you open a file the Data File Editor Window is displayed.
Note: You can't open a file if the backup option is selected and there isn't enough disk space for the backup file (see the section Data Tools Settings).
The Data File Editor window is split into two panes:
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.
The right-hand pane shows one record at a time of formatted data at field level. A separate line displays each field. To invoke the right-hand pane, you need to create a record layout file. For further information, see the section Record Layouts.
Both these views are described in more detail below.
Figure 12-2: Data File Editor Window
You can select a record by clicking on the field or using the up and down arrow keys. The currently selected record is highlighted.
When the focus is on this pane, the status bar at the foot of the NetExpress window shows the following information, going from left to right (see Figure 12-3):
For variable length records, it also shows the minimum and maximum record lengths defined under Minimum length and Maximum length. 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 further information, see the section Viewing Non-sequential Files.)
Figure 12-3: Relative File Record View and Status Bar
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, you can use the up and down arrow keys from these two columns. The currently selected field is highlighted. To select the first field, press Home. To select the last field, press End.
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 NetExpress window shows the following information, going from left to right (see Figure 12-4):
For variable length records, it also shows the minimum and maximum record lengths defined under Minimum length and Maximum length. For fixed length records, it shows (Fixed).
Figure 12-4: Relative File Field View and Status Bar
If you have both views displayed you can use two methods of keeping the two views in step:
If you have positioned the cursor in a field or record, you can use Synchronize Views to force the cursor to the same position in the other pane. You can find this option either by clicking DataTools on the View menu or right-clicking in the Data File Editor window.
If you have updated data in the unformatted view, you can see the effect of the changes in the formatted view by using Refresh Formatted Pane. You can find this option by clicking DataTools on the View menu.
The methods for creating records are different for sequential, relative and indexed files because sequential files do not have keys, and relative and indexed files have different types of keys. Special considerations apply to ESDS files.
If you have a record layout file loaded, you can choose to base a new record on one of the existing record layout types or have the new record filled with padding bytes. (See the section Record Layouts.) 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 no record layouts are loaded, the appropriate padding byte is used and the record is set 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 entered during the insert process takes precedence over conditional data associated with the selected record layout (see the section Record Layouts).
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).
You can only create a new record in a 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 physically positioned at the end of the file, but 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 (see the section Viewing Non-sequential Files).
Once the record has been appended, you enter the field values in an editing session.
You can delete single or multiple records from any type of data file except for ESDS files.
The multiple delete procedure runs even if insufficient records are available. The delete continues until the end of the file when a message displays the number of records deleted.
Note: You should ensure that the Delete warning check box is selected. For further details see the section Data Tools Settings.
You can view your data files in two ways:
Data File Editor can display your ANSI or EBCDIC data in hexadecimal. 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.
Figure 12-6 shows a file with hexadecimal display.
You can use the File Information dialog box to check on the current Data file Editor settings as well as the file details. To open the File Information dialog box, select Data Tools from the View menu and then select File Information.
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 12-5). This toolbar shows you which character set and selected key are currently in use.
To display the Data File Toolbar, select Dockable Windows from the View menu and then select the Data File Toolbar checkbox.
Figure 12-5: 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 12-5). 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 (record number) that you see in the status bar at the foot of the NetExpress window starts from zero. The column number also starts from zero for consistency with the line number.
If you then move backward in the file, the line number decreases by one for each record moved and appears as a negative number.
If you move forward in the file, the line number increases by one for each record moved.
Net Express enables you to:
Notes:
There are several ways of moving to a particular record for editing:
You can edit data in record view by overtyping, inserting or deleting data.
When you insert or delete data in record view, you can create a shift in all of your data, corrupting the fields following the insert or delete. You can avoid this by setting Overtype Mode.
If Update warning is selected you see an Update warning message.
For more information about these settings see the section Data Tools Settings.
You can edit alphanumeric or numeric data directly in any field.
Modes allowed 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 pulled in at the right-hand edge of the field.
If Update warning is selected you see an Update warning message (see the section Data Tools Settings).
Notes:
If you have hexadecimal values displayed, you can edit them directly. This enables you to enter invalid data into your files for testing purposes.
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 12-6 shows a file with hexadecimal display.
Figure 12-6: File with Hexadecimal Display
You can reset a whole field to spaces or zeros by initializing it. You can also initialize all the fields in a record. An alphanumeric field is initialized to spaces, a numeric field to zeros.
If you have created any conditional record layouts (see the section Types of Record Layout), the field used for testing the condition remains unaffected by initializing a record.
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, while if you increase the length of a record, the extra bytes are filled with the current padding byte.
Data File Editor offers the following types of search:
A replace string shorter than the search string results in padding characters filling the empty bytes. Replace strings longer than the search string are truncated.In this way the consistency of field positions within the record is preserved.
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 (see the section Record Layouts).
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, you see a message "Could not find search string after the current edit position".
Note: When you are searching on a numeric key with COMPUTATIONAL usage, you must enter the hexadecimal value. Data File Editor does not format data entered 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 before printing it. If you haven't loaded a record layout file, you can only print or preview your data in the unformatted view (see the section Record Layouts for further details).
If you are printing or previewing from the unformatted view, you can:
If you are previewing records, you can change the magnification of the display.
Notes:
The facilities for previewing or printing data from the formatted view are the same as for the unformatted view except for the following differences:
This section gives you background information about record layouts. To find out how to create a record layout and associate the record layout with a data file, see the help provided in the NetExpress online help file. (Click on the Help Topics button, ensure that the Contents tab is at the front and then select Development Environment, Data Tools, Record Layout Editor.)
For more help, refer to the chapter Maintaining and Creating Data Files in your Getting Started. This chapter contains a tutorial, part of which takes you through the process of creating a record layout file.
A record layout is a representation of the structure of a data record. If you have a record layout available for a data file, browse and edit the data file at the individual field level within a record and see the numeric values of data held in non-display fields. COBOL programs contain record layouts. An example of a COBOL record layout is:
01 REC.
02 EMP-CODE.
03 EMP-POSITION PIC
X.
03 EMP-NUM PIC
9(6).
02 EMP-AGE PIC
99 COMP.
02 EMP-YEARS-WITH-COMPANY PIC 99 COMP.
In this example EMP-AGE
and EMP-YEARS-WITH-COMPANY
are numeric non-display fields.
You use the Record Layout Editor to create a record layout (.str) file that contains one or more record layouts for your data. A record layout file contains information describing the records in your data file, the name, length and picture of each field. If your data file includes multiple types of records, you can capture these multiple record layouts in one record layout file.
Once you have created the record layout file for a particular data file, you can keep it and use it whenever you want to work with that data file. You only need to recreate the record layout file if you either change the record layout in your COBOL program or wish to add a new conditional record layout.
The Record Layout Editor uses the debug information (.idy) file from your compiled COBOL program to create a record layout file. Without an associated .idy file you cannot create a record layout file. You create an .idy by compiling your program for debug. If your COBOL record layout contains FILLER items, you must compile with the INCLUDE-FILLER Compiler directive, in order for the record layout file to include the FILLERs. (For more details on compiling for debugging, see the topic Development Environment in the online help.)
Record layout files are also used by the Data File Converter (see the section Converting Data Files).
Note: If your data file has a very simple record format, you may not wish to create a record layout file for your data's formatted view.
There are two types of record layout:
Loading or associating a record layout file with your data file enables you to see your record data formatted at field level in the right-hand pane of Data File Editor's window (see the section Data File Editor Window).
If a record is found which doesn't match any of the available layouts or contains an invalid OCCURS DEPENDING ON RANGE, you see a warning message in the field view pane and status bar.
You must save the record layout file in the same directory as the data file and use the same basename.
You can convert data files between file organizations and formats using the Data File Converter.
Converting files from one format to another enables you to restructure data. For example, you can convert from sequential organization to indexed, or add extra secondary indices as the needs of an application change.
The Data File Converter also provides an easy method for data conversion between EBCDIC and ANSI, and removes the need for you to recreate data already produced or to write special conversion programs. If records contain non-text data items, such as COMPUTATIONAL data, you can use record layouts to define the data items to be converted and those data items that should remain unconverted. For more information on how to create a record layout file, see the section Record Layouts.
The Data File Converter can also convert internal floating-point formats between S/370 format and IEEE format using the record layout descriptions.
You can increase or decrease the minimum and maximum record length for the new file:
Note: If you request a conversion of a sequential file to an indexed file with unique keys, and some of the records contain duplicate key values, Data File Converter ignores these records and does not convert them. At the end of the conversion Data File Converter informs you of the number of records rejected.
You can use the file conversion to convert:
A mainframe file should be transferred to the PC in binary format. If this file is initially a variable-length file, you can ask your administrator to use the mainframe program VRECGEN to perform an initial reformat of the file on the mainframe. You can then process the file using Data File Converter. When you want to upload the file to the mainframe, you should use Data File Converter to convert it to VRECGEN2 format, then ask your adminstrator to use the mainframe program VRECGEN2 to reformat the data for the mainframe.
You may need to convert report files that have either been produced on the mainframe then downloaded to the PC or created by a mainframe application run on the PC. A mainframe report file contains carriage control characters which the Data File Converter converts to PC-printable formats. When the output file is the mainframe file, the record length includes the carriage control character. When the output file is the PC print file, the record length is solely the data length.
If you specify the input file as a mainframe print format file, but it was
created on the PC you may receive error message 139, Input file not "real"
mainframe report format
. You can prevent this by ensuring that normal
mainframe dialects are used to create an EBCDIC report file.
Mainframe report files can only be converted to PC print files. Similarly a PC print file can only be converted to a mainframe report file. The mainframe report file should be an EBCDIC-encoded file and the PC print file should be ANSI-encoded.
When you enter the input filename, the Data File Converter uses the process outlined in section File Types and Record Lengths to read the input file details. You need to specify the output file's name and you can change the default organization and record format values picked up by the Data File Converter. If no file details are available, you need to enter them.
If you have selected the output file to have indexed organization, you need to define the keys for the new file (see the section Defining Keys).
For more information about using VRECGEN, VRECGEN2 and the command line interface, see the File Conversion Utilities chapter.
Use Fix File Index to rebuild the index of a corrupt indexed file. For more information, see the section Fix File Index in the Rebuild chapter.
Copyright © 1998 Micro Focus Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
File Conversion Utilities |