Non-Join Logical file in AS400 |
Introduction
Non-Join Logical files are created on single or multiple record formats from the same or multiple physical files. So basically, It's a simple logical file.
There are two types of Non-Join Logical files
- Single Record Format Logical File
- Multiple Record Format Logical File
Single Record Format Logical File
A logical file created over a single physical file is called a single record format logical file.
Example of Single Record Format Logical File
Let's create a physical file and then create a single record format logical file on that physical file.
- DDS script for the physical file PF1
A R FMT1
A ID 10A
A NAME 20A
A AGE 3P 0
A ADDRESS 50A
Create the PF1 using the CRTPF command
- Create LF1 on the PF1 as below having key fields defined as below.
A R FMT1 PFILE(PF1)
A K ID
A K AGE
PFILE keyword is used to refer to the Physical file. Either we can use PFILE(LIB1/PF1)
or PFILE(PF1)
, here the Library name is optional to use with the PFILE keyword.
CRTLF command is used to create the Logical file. Make sure when you are creating the logical file. The library list must be set and contain the entry of the library in which PF resides. otherwise, your LF would not get compiled.
- Create LF2 on the PF1 as below having UNIQUE key fields defined as below.
A UNIQUE
A R FMT1 PFILE(PF1)
A K ID
A K AGE
- Create LF3 on the PF1 as below having UNIQUE key fields defined and only Id, name, and age fields contained in it as below.
A UNIQUE
A R FMT1 PFILE(PF1)
A ID 10A
A NAME 20A
A AGE 3P 0
A K ID
- Create LF4 on the PF1 as below which same as PF1 as below.
A R FMT1 PFILE(PF1)
Multiple Record Format Logical File
A logical file created over multiple record formats two or more physical files
Example of Multiple Record Format Logical File
Let's create two physical files and then create a multiple record format logical file on that physical file.
- DDS script for the physical file PF1
A R RMT1
A ID 10A
A NAME 20A
A AGE 3P 0
A ADDRESS 50A
Create the PF1 using the CRTPF command.
- DDS script for the physical file PF2
A R FMT2
A ID 10A
A PHONE 10A
A STATUS 6A
Create the PF2 using the CRTPF command.
- Create multiple record format LF named LF1 on the PF1 and PF2 as below
A R FMT1 PFILE(PF1)
A K ID
A R FMT2 PFILE(PF2)
A K ID
A K PHONE
As we can see this Logical file contains two record formats FMT1 and FMT2 from file PF1 and PF2 respectively and is referred to in LF using the PFILE keyword.
Create the LF using the CRTLF command.
Related Post
- Logical file in AS400
- Join Logical file in AS400
- Join two physical files to create Join logical file in AS400
- Join more than one physical file field to create Join logical file in AS400
- Use JDUPSEQ keyword to arrange duplicate records in secondary file in join logical file in AS400
- Join fields with different attributes to create a Join logical file in AS400
- Fields that never appear in Record format in Join Logical File in AS400
- Specify the key fields in the Join Logical File in AS400
- Joining three or more physical files to create Join Logical File in AS400
- Joining physical file to itself in Join Logical File in AS400
- Select and Omit criteria in Logical file in AS400