PreviousData File Editor Directory FacilityNext

Chapter 5: Data File Editor Tutorial

This chapter demonstrates how to use the main features of the Data File Editor. The Data File Editor is a tool for editing all file types supported by Micro Focus. The files can use either ASCII or EBCDIC character sets. You can edit them in unformatted mode or formatted against the record structure contained in a COBOL copyfile.

5.1 Overview

The tutorial uses an indexed personnel file containing employee records for a small business.

At the end of this tutorial you should be able to:

5.2 Preparation

The tutorial uses the following files, which will have been copied to the directory $COBDIR/demo/dfed during installation of Server Express:

Before you begin the tutorial, you should copy these files to a working directory, set execute permissions on them, and set your default directory to the working directory.

5.3 Sample Session

To start the Data File Editor, start the Server Express Integrated Development Environment, select the Alternate menu, and select F4=data-file-editor.

5.3.1 Loading the Data File

To load the data file:

  1. Select the Data File Editor's Alternate menu and press F3=load-file. The Load File menu appears, as shown in Figure 5-1.



    Figure 5-1: The Load File Menu

  2. Type in the file name of the data file:
    dfeddemo.dat

  3. Press Enter. The file is now loaded.

5.3.2 Defining a Record Structure

The records cannot be viewed formatted against a structure until you define that structure. To define the structure, you must load the dfeddemo.idy file that was created when dfeddemo.cbl was compiled (using the Compiler from Micro Focus COBOL Version 3 or later).

  1. Select the Alternate menu and press F8=structure-selector. The first Structure Selector screen appears, as shown in Figure 5-2.



    Figure 5-2: The Load IDY File Screen

  2. This screen asks you for the name of a .idy file. Type:
    dfeddemo

    You do not need to type the .idy extension; it is added automatically.

  3. Press Enter. The .idy file is loaded, and the structures declared in the program dfeddemo.cbl are displayed, as shown in Figure 5-3.



    Figure 5-3: The Loaded Structure Screen

The data file has three record types - employee, executive and manager. These record types are defined by three structures: employee-rec, executive-rec and manager-rec respectively. You can define a default structure for one type (such as the employee record - because there are more of those) and conditional structures for the other types.

To define employee-rec as a default structure:

  1. Move the cursor to employee-rec in the .idy file.

  2. Press F6=accept-default-structure. EMPLOYEE-REC appears in the structure list with an asterisk preceding it and the word "Default" after it. This structure is now defined as default.

To define executive-rec as a conditional structure:

  1. Move the cursor to executive-rec further down the .idy file.

  2. Press F7=accept-conditional-structure. The executive-rec structure has now been cut from the main body of definition and is displayed alone. You must now define a condition to specify when this record structure should be used.

    In this file, all records have a field to indicate the type of employee. The values for this field are:

    E executive
    M manager
    1 grade 1 employee
    2 grade 2 employee
    3 grade 3 employee

    In the executive records, this field is called ex-position.

    So, move your cursor to the ex-position field and press Enter.

  3. You are asked to enter the condition value to be used for this field. For executive-rec, type:
    E

    and press Enter. The box is now hidden so that you can specify more conditions, if necessary.

  4. To commit this structure, press F7=accept-structure. The original program definitions are redisplayed, and EXECUTIVE-REC appears in the structure list.

Now repeat this process for the manager record.

  1. Move the cursor to manager-rec further down the .idy file.

  2. Press F7=accept-conditional-structure.

  3. Move the cursor to mn-position and press Enter.

  4. Type:
    M

    and press Enter.

  5. To commit the structure, press F7=accept-structure

You have now defined a default structure and two conditional structures. To make a listing file of the details of these structures, suitable for printing:

  1. Press F5=structure-box. The structure list menu appears.

  2. Press F2=list-structures-to-file and type:
    dfeddemo

  3. Press Enter. The file dfeddemo.lst is created.

  4. Press F5=exit-structure-box to leave the structure box.

5.3.3 Saving the Structure File

To save the structure file so that you do not need to define it each time you load the file:

  1. Select the Alternate menu, press F4=save-str-file and type:
    dfeddemo

  2. Press Enter to save the file as dfeddemo.str. Giving the structure file the same name as the data file, means that, in future, it will be automatically loaded with the data file.

  3. Press Escape to leave Structure Selector.

5.3.4 Using the Structure File

We need to be in formatted mode to use the structure file.

  1. Press F2=toggle-format. The first record is displayed, formatted against its record structure, as shown in Figure 5-4.



    Figure 5-4: Formatted Display of a Record

  2. Use the F9=prv-rec and F10=next-rec keys to scroll backward and forward in the file. Each record is automatically formatted.

5.3.5 Inserting a Record

To insert a record in your data file:

  1. Press F3=insert-record

    The word "Spaces" and a list of defined record structures is displayed. In this case, another executive has been appointed, so we want to add a record for that person.

  2. Select EXECUTIVE-REC in the structure list and press Space.

    A new executive-rec is inserted. It has "E" in the ex-position field to define this record as an executive-rec.

  3. This is the third executive record, so type:
    000003

    in the ex-emp-num field.

  4. Now enter some more details for the new executive.

  5. To save this record and move to the next record, press F10=next-rec.

You can also try other functions, for example:

  1. To display the file information, press F10=file-info in the Alternate menu

  2. To remove the file information from the display, press Escape

  3. To edit data in hexadecimal, press F2=toggle-hex in the Alternate menu .

  4. To return to normal editing, press F2 in the Alternate menu .

5.3.6 Deleting a Record

The personnel file needs to be updated because Darren A. Hayes has left the company.

We will perform a search for the surname "Hayes" to find the record for Darren A. Hayes. All records have a surname field in the same position in each record. We will use an executive record to define the search argument, but you could use the employee or manager records because the search is based on the position of the field, not its name.

  1. Display an executive record and move the cursor to the ex-surname field.

  2. Press F2=search on the Control menu to bring up the Search menu. Because the ex-surname field is not a key field, you need to search for the record on a string search.

  3. Press F4=search to select the search function. The window shown in Figure 5-5 is displayed.



    Figure 5-5: Search Window

  4. Type the employee's surname to identify the record you want:
    Hayes

    The search is case-sensitive, so you must enter the surname exactly as shown.

  5. Press F2=toggle-search-direction until "Backward Search" is displayed on the information line. You want to search backward, because Hayes is an employee, and employee records occur before executive records.

  6. Press Enter.

    The record for Darren A. Hayes is displayed.

  7. Press F4=delete-record to delete the record.

5.3.7 Resequencing the Data File

The read key is used to sequence the records when the data file is displayed by the Data File Editor. You can resequence the file by changing to a different read key:

  1. Press F10=file-info in the Alternate menu. The configuration screen is displayed, as shown in Figure 5-6.



    Figure 5-6: Configuration Screen

  2. In the key list, the arrow points to the key currently being used as the read key. Use the cursor to select a new key.

  3. Press F2=change-read-key. The file is resequenced, based on that key.

    If you are displaying the file in unformatted mode, you can see the highlighted part of the file change when you change the key.

5.3.8 Creating a File

You can create a new file from within the Data File Editor. We will create a file named yourdemo.dat, which is similar to dfeddemo.dat

  1. Save the current file, if necessary, and press Escape to exit.

  2. Press F5=new-file in the Alternate menu. Type in the filename yourdemo and press Enter. This displays the Create File screen, shown in Figure 5-7, and places your cursor on the file organization box.



    Figure 5-7: Create File Screen

  3. Select Indexed, and press Space. This defines the file as an indexed file.

  4. Press Tab until the cursor is in the Minimum field.

  5. Type 348 in the Minimum field, and press Tab.

  6. Type 628 in the Maximum field, and press Tab.

5.3.9 Defining Record Keys

When an indexed file is created, you must define its keys.

  1. Press F2=define-key. The Define Key screen, shown in Figure 5-8, appears.



    Figure 5-8: Define Key Screen

    The type of key is displayed at the top of the window. The first key you define is the Prime Key, followed by First Alternate Key, Second Alternate Key, etc.

  2. Press Tab to move between the options, and press Space to toggle between Y and N to set the various settings available on the key.

    The format of the key range is:

    key-component-start-position:key-component-length

    For example, for a key starting at byte 1 and two bytes long, the key range would be 1:2.

    For split keys you can repeat the parameters, using a comma to separate them. For example, in a split key with two components, when the first starts at byte 1 and is two bytes long and the second starts at byte 4 and is three bytes long, the key range would be 1:2,4:3.

  3. When you have finished defining the key, press Enter.

  4. When you have finished defining all keys, press Escape to return to the Create File Screen.

  5. To create the file, press Enter. An empty file is displayed so that you can insert the records.


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

PreviousData File Editor Directory FacilityNext