PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Creating a Logical File or Index

View previous topic View next topic Go down

Creating a Logical File or Index

Post  sivakumar on Mon Jul 19, 2010 5:44 pm

A logical file provides a different view of a physical file. The most common and simplest use of logical files is to change the order of the data. To define a logical file, you use the DDS specifications. You must start the Programming Development Manager and create a member with TYPE of LF (for logical file).

Usually, this goes in the object QDDSSRC. Here is how to make a logical file named CUS01 which orders the CUS physical file by name.
For simple logical files like this, the first line defines the record name of the physical file that has the data. This line also has the PFILE function that names the physical file.

Then, add a K definition for each key file.
A R CUSREC PFILE(CUS01)
A*
A K NAME
Name the member in QDDSRC the same as the desired file. In this case, I named it CUS01.
Then, you must compile or create the file. In PDM you can do this with the option 14. When you use option 14, you actually execute the

command:

CRTLF FILE(MYLIB/CUS01) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUS01)

The AS/400 knows to use this command because you specified that this member is describing a LF.
Add a SELECT spec to select only customers with STATUS of 'A'
A R CUSREC PFILE(CUS01)
A*
A K NAME
A S STATUS COMP(EQ 'A')

Or to omit records with a STATUS of 'D'
A R CUSREC PFILE(CUS01)
A*
A K NAME
A O STATUS COMP(EQ 'D')

An RPG program uses logical files almost identically to physical files.

sivakumar

Posts : 174
Join date : 2009-07-27
Age : 30
Location : Chennai

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum