Creating a logical file

 

You can 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. You can do this using the source entry utility (SEU). 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 ORDHDRL file with one member of the same name is placed in the DSTPRODLB library.

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 32KB.

Views are similar to logical files. You can create views using iSeries™ Navigator or using the CREATE VIEW SQL statement.

 

Parent topic:

Setting up logical files

 

Related concepts


Working with source files
Identifying which record format to add in a file with multiple formats
Creating and using a view

 

Related reference


Create Logical File (CRTLF) command
CREATE VIEW