Create a logical file

This topic shows how to create a logical file using data description specifications (DDS).

The physical file or files on which the logical file is based must already exist before you create a logical file.

To create a logical file, follow these steps:

  1. Type the DDS for the logical file into a source file. This can be done using the source entry utility (SEU) or another method. The following example shows the DDS for logical file ORDHDRL (an order header file):
    |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
         A* ORDER HEADER LOGICAL FILE (ORDHDRL)
         A          R ORDHDR                    PFILE(ORDHDRP)
         A          K ORDER
     

    This file uses the key field Order (order number) to define the access path. The record format is the same as the associated physical file ORDHDRP. The record format name for the logical file must be the same as the record format name for the physical file because no field descriptions are given.

  2. Create the logical file. You can use the Create Logical File (CRTLF) command. The following example shows how the CRTLF command can be typed:
    CRTLF  FILE(DSTPRODLB/ORDHDRL)
           TEXT('Order header logical file')

As shown, this command uses some defaults. For example, because the SRCFILE and SRCMBR parameters are not specified, the system uses DDS from the IBM-supplied source file QDDSSRC, and the source file member name is ORDHDRL (the same as the file name specified on the CRTLF command). The file ORDHDRL with one member of the same name is placed in the library DSTPRODLB.

You can create multiple logical files over a single physical file. The maximum number of logical files that can be created over a single physical file is 32K.

Similar to logical files are views. Views can be created using iSeries™ Navigator or using the CREATE VIEW SQL statement.

Related concepts
Work with source files
Identify which record format to add in a file with multiple formats
Create and use a view
Related reference
Create Logical File (CRTLF) command
CREATE VIEW