Previous Topic Next topic Print topic


Create an Indexed Data File

Use this procedure to create an indexed data file. To create a (record) sequential, line sequential, or relative data file, see Create a Non-indexed Data File.

  1. From the Data File Tools window, select File > New, or click (New File).

    The New dialog box appears.

  2. Select Data File, then click OK.

    The Create New File dialog box appears.

  3. In the Filename field, type the name of the data file.
    Tip: You can specify:
    • An absolute path: for example, c:\path\to\file\dat-name.dat.
    • A relative path: for example, dat-name.dat. (The .dat file is created in the directory in which Data File Tools was started.)
    • A Fileshare path: for example, $$FS-server-name\dat-name.dat.
  4. If you are applying a structure file to the data file, click Browse to the right of the Structure File (optional) field, then use the Open dialog box to navigate to and select a structure (.dfs) file.

    If you do apply a structure file, the details within it are used to populate the File Details section.

  5. If you have not applied a structure file, in the File Details section, click beside Organization, then select Indexed.
  6. Click beside File Format, then select an indexed file format.

    For an indexed file, you must specify a primary key, and may specify one or more alternate keys.

  7. Click Define Keys.

    The Key Information dialog box appears.

  8. Add a primary key:
    1. In the Key section, click Add.

      A primary key is created, with a default component. A component defines the start position and length of the key within each record.

    2. In the Key compression section, select the appropriate check boxes:
      Leading spaces
      Removes the leading spaces within the value of the key.
      Trailing spaces
      Removes the trailing spaces within the value of the key.
      Duplicates
      For alternate keys only. Only the first duplicate key is contained in the file; subsequent duplicate values are not stored, but information is stored to enable correct recreation of the keys.
    3. Click the Component tab. Details for the default component, created when the key was added, appears.
    4. In the Key Component section, specify the Offset and Length values of the primary key.

      For example, if the key is going to be the first 3 bytes of the record, specify Offset:0, Length:3.

    5. To create a split key, click Add and repeat the last step to create one or more additional components to the key.
      Tip: To delete a component, select it, then click Delete.
    6. Click OK.

      The primary key is created.

  9. If required, add an alternate key:
    1. Click Define Keys.
    2. In the Key section, click Add.

      An Alt Key <number> key is created, with a default component.

    3. In the Key Options section, select the appropriate check boxes:
      Allow duplicates
      Allows duplicate values for this key.
      Sparse
      Allows you to define an ANSI or EBCDIC value that when used as the value of this key, will not be stored in the index file; thus saving space.
    4. In the Key compression section, select the appropriate check boxes:
      Leading spaces
      Removes the leading spaces within the value of the key.
      Trailing spaces
      Removes the trailing spaces within the value of the key.
      Duplicates
      For alternate keys only. Only the first duplicate key is contained in the file; subsequent duplicate values are not stored, but information is stored to enable correct recreation of the keys.
    5. Click the Component tab.

      Details for the default component, created when the key was added, appear.

    6. In the Key Component section, specify the Offset and Length values of the alternate key.

      For example, if the key is going to be the next 3 bytes of the record after the primary key, specify Offset:3, Length:3.

    7. To create a split key, click Add and repeat the last step to create one or more additional components.
      Tip: To delete a component, select it, then click Delete.
    8. Click OK. The alternate key is created.
  10. If the records will be of variable length, select Variable length records.
  11. Specify the Min Length (only applicable for variable length records), and Max Length values. All the details you specify in the File Details section are written to the file header of the indexed file.
  12. Click Create File.

    The file is created, then opened in the editor.

Previous Topic Next topic Print topic