what is the difference between a physical and logical file on the as400
i5/OS has a database which stores data in files. These are called physical files.
The Physical file stores the actual data.
The data is written to a physical file in arrival sequence. This data can be accessed by RRN (relative record number) where the first entry on the file (also known as a table) is relative record number 1. ie: the first record in the file. The next record is RRN=2 then RRN3 and so on.
If you want to access the data using a sequence of something on the file (for example CUSTOMER sequence) then you would design and create a logical view of this physical file specifying that you want it sequenced by customer.
The Logical File is a sequenced VIEW of the data in the Phsyical FIle.
Logicals can be used for updating, creating and deleting data within the physical that it is scoped over.
Join Logicals - are an advanced form of logical file selecting and sequencing data from more than one physical.
Wait - theres more
You can also add a KEY (the keyed sequence field used in a logical) to a physical file itself.
So a non-keyed FIFO Physical file definition might look like this
A PRJCDE 3 COLHDG('PROJECT CODE')
A PRJDESC 50 COLHDG('DESCRIPTION')
A USRLIB 2750 COLHDG('USER LIBL')
A SYSLIB 165 COLHDG('SYSTEM LIBL')
A CURLIB 10 COLHDG('CURRENT LIBRARY')
A CHGUSER 10 COLHDG('LAST CHANGED BY')
A CHGDATE L COLHDG('LAST CHANGED ON')
A DATFMT(*ISO)
A CHGTIME T COLHDG('LAST CHANGED AT')
This same Phsyical file when defined to have a key sequence of the Project Code (PRJCDE) might look like this:
A logical over the same File sorting by Current Library (CURLIB) would look like this:
- Post Reply


Recent comments
6 hours 40 min ago
8 hours 12 min ago
3 days 7 hours ago
5 days 1 hour ago
1 week 1 hour ago
1 week 5 hours ago
1 week 18 hours ago
1 week 18 hours ago
2 weeks 4 days ago
2 weeks 5 days ago