Академический Документы
Профессиональный Документы
Культура Документы
Logical Files:
Create a Logical file Understand the part of Logical files. Commands related to files.
Logical File:
A logical file is provide access the data stored in one or more physical files. The features unique to logical files include the following: 1. Logical files do not contain data. 2. Access one or more physical files in an arrival sequence or in any single or multiple field (key) value order. 3. A physical file may be processed by any number of logical files. 4. Two or more logical files may share the same access path. 5. Omit and select criteria may be specified in a logical file to process only the required physical file data. 6. A logical file may include multiple record formats. Each format however must relate to one or more physical files and include at least one key field. 7. One logical file with multiple record formats may process only the required physical file data. 8. A logical file with multiple record formats may be used to process the data from more than one physical file. The file record formats accessed may be of different lengths. 9 During processing a physical files field attributes may be changed by a logical file. However, the data stored in the physical file not be modified. Logical files may be specified as either nonjoin or join. A nonjoin logical file processes each record individually from one or more physical files. Join logical files however create a single record from the selected fields from two or more physical files. The type of logical file (nonjoin or join) specified is determined in the related DDS coding. In the following text, the processing logic and DDS syntax for nonjoin logical files are introduced first, followed by the coding requirements associated with join logical files. NONJOIN LOGICAL FILES (ONE-RECORD FORMAT) All logical files are formatted and defined by DDS coding. The DDS coding for nonjoin logical files is specified in the following order. 1. File level entries (optional) 2. Record level entries 3. Field level entries (optional) 4. Key field level entries (optional) 5. Select/omit level entries (optional). Non-join logical files may specify more than one record format. If two or more physical files with different record formats are to be used by a logical file, separate PFILE keywords must be specified. When the record formats are the same, only one PFILE keywords is required. A maximum of 32 physical files may be referenced in one PFILE keyword. When two or more physical files with a logical file accesses different record formats. *NONE may be specified as a key field substance for any of the following conditions: 1. The related keyfields from the physical files do not have the same attributes. 2. The key fields from the physical files have the same attributes, but they are not to be merged and sequenced together. Specify the entries in the following order to define a simple or multiple format logical file: 1. File-level entries (optional) 2. Record-level entries
S R CHOWDARY
How to create simple logical file? Create student pf file as discussed above. Like physical file create logical file as shown below. Press F6 & IN NEXT STEP YOU HAVE TO WRITE SOURCE TYPE AS LF & SOURCE MEMBER
Start Source Entry Utility (STRSEU) Type choices, press Enter. Source file . . . . . . . . . . > Library . . . . . . . .> Source member . . . . . . . . . Source type . . . . . . . . . . Text description . . . . . . . qddssrc Name, *PRV BIZLIB Name, *LIBL, *CURLIB, *PRV LSTUDENT Name, *PRV, *SELECT LF Name, *SAME, BAS, BASP... LOGICAL FILE FOR STUDENT
F5=Refresh
F12=Cancel
Columns . . . : 1 71 Edit SHEET/QSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ''''''' ****************** End of data **************************************** F3=Exit F4=Prompt F5=Refresh F9=Retrieve F16=Repeat find F17=Repeat change Member LSTUDENT added tofile BIZLIB/MYDDS. F10=Cursor F11=Toggle F24=More keys +
AFTER TYPING IPLF AS SHOWN ABOVE USER GETS THE FOLLOWING PROMPT
S R CHOWDARY
Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* ''''''' ******************End of data ****************************************
LF
F11=Previous record
Enter reference file using PFILE(FILE NAME) function key as well as record format name as shown below :
Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 A R SR PFILE(STUDENT) ****************** End of data ****************************************
Prompt type . . . Name Type Name R SR Functions PFILE(STUDENT) F3=Exit F4=Prompt F12=Cancel
LF
Use
S R CHOWDARY
Prompt type . . . Name Type Name K ROLL Functions F3=Exit F4=Prompt F12=Cancel
LF
Use
Press F3 and use option 14 to compile the above file and create object in BIZLIB and Runqry command for above logical file gives following output:
Display Report Report width . . . . . : Position to line . . . . . Shift to column . . . . . . Line ....+....1....+....2....+....3....+.... ROLL SNAME CCD CORS ADD CITY 000001 101 sneha vv VB pune pune 000002 102 ramesh hh C mumbai mumbai 000003 103 titu iii AS mumbai pune 000004 104 rahul AS400 VB pune pune ****** ******** End of report ******** 39
Reference file name and key field gives all field from related physical file. But in logical file user is able to select particular field as shown below. Just insert the required field name as per above define sequence:
S R CHOWDARY
F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F17=Repeat change F24=More keys COPYRIGHT IBM CORP. 1981, 2002.
********
Also you are able to define multiformat logical file as shown below:
Columns . . . : SEU==>
71
Edit
BIZLIB/QDDSSRC LSTUDENT
S R CHOWDARY
Columns . . . :
1 71
Edit
BIZLIB/QDDSSRC
SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 A R RS PFILE(STUDENT) 0002.00 A ROLL COLHDG(ROLL NO) 0003.00 A NAME TEXT(STUDENT DETAIL) 0004.00 A CORS 0005.00 A K ROLL ****************** End of data ****************************************
F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F17=Repeat change F24=More keys COPYRIGHT IBM CORP. 1981, 2002.
S R CHOWDARY
Shift to column
. . . . . .
The following keywords are select and omit level keywords: 1. COMP 2. RANGE 3. VALUE HOU TO USE ABOVE KEYWORD WITH SELECT & OMIT:
Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ ***************Beginning of data ************************************* 0001.00 A R RS PFILE(STUDENT) 0002.00 A ROLL COLHDG(ROLL NO) 0003.00 A NAME TEXT(STUDENT DETAIL) 0004.00 A CORS 0004.01 A K ROLL 0005.00 A S ROLL COMP(GT 102) ****************** End of data **************************************** Prompt type . . . LF Sequence number . . . Length Data Type 0004.01 Use
Name Type Name S ROLL Functions COMP(GT 102) F3=Exit F4=Prompt F12=Cancel
Decimal Positions
FOR
THE
SELECTED
F11=Previous record F24=More keys
S R CHOWDARY
21
Position to line . . . . . Line ....+....1....+....2. ROLL NO SNAME CORS 000001 103 titu iii 000002 104 rahul AS400 ****** ******** End of report
********
Like that we are able to use range and value keyword with logical file. Now use of omits keyword with logical file.
Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF.....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ ***************Beginning of data ************************************* 0001.00 A R RS PFILE(STUDENT) 0002.00 A ROLL COLHDG(ROLL NO) 0003.00 A NAME TEXT(STUDENT DETAIL) 0004.00 A CORS 0004.01 A K ROLL 0005.00 A O ROLL COMP(GT 102) ****************** End of data *************************************
F3=Exit F4=Prompt F5=Refresh F9=Retrieve F16=Repeat find F17=Repeat change COPYRIGHT IBM CORP. 1981, 2002.
Note: Omit keyword is always used with DYNSLT to omit the value. This is logical file level keyword.
S R CHOWDARY
Position to line . . . . . Line ROLL NO SNAME CORS 000001 100 ABC AS400 000002 101 sneha vv ****** ******** End of report
********
You can use this k/w on one field & one file as shown below
Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ ************* Beginning of data ************************************* 0001.00 A R RS PFILE(STUDENT) 0002.00 A ROLL COLHDG(ROLL NO) 0003.00 A SNAME TEXT(STUDENT DETAIL) 0004.00 A CORS 0005.00 A K ROLL 0006.00 A O ROLL COMP(EQ 102) 0007.00 A S ROLL COMP(GT 100) **************** End of data ****************************************
F3=Exit F4=Prompt F5=Refresh F16=Repeat find F17=Repeat change COPYRIGHT IBM CORP. 1981, 2002. OUTPUT OF THIS COMPARISON IS
F11=Toggle
S R CHOWDARY
Position to line . . . . . Line ....+....1....+....2. ROLL NO SNAME CORS 000001 101 SNEHA VV 000002 103 titu iii ****** ******** End of report
21
********
Bottom
F3=Exit
F12=Cancel
F19=Left
F20=Right
F21=Split
Output of this keyword is where roll number having value 102 gets omitted.
S R CHOWDARY
Display Report width . . . . . : 21 Position to line . . . . . Shift to column Line ....+....1....+....2. ROLL NO SNAME CORS 000001 101 sneha vv 000002 103 titu iii ****** ******** End of report ********
Report . . . . . .
S R CHOWDARY
Questions related to above session: 3.1: Flat Files Create flat file using the command CRTPF and specifying the record length. Add records to the file by using UPDDTA command. View the contents of the file by using the RUNQRY command. Try if you can see the DDS for the same. 3.2: Physical & Logical Files
Write the DDS source to create a Physical file. Create the following physical files and populate them with data:
CUSTM
No. 1 2 3 4 5 6 7 8
Field Name
CPHONE CLNAME CFNAME CADDR CBILL COWED CPYDT STATUS
Length
10,0 10 10 20 6,2 6,2 6,0 1
Data Type
P A A A P S S A
Key
K
Description
Customer Phone No Customer Last Name Customer First Name Customer Address Customer Billing Amount Amount Owned Payment Date Customer Status
Hint : Use Text keyword. CUSTM CUSTM No. 1 2 3 Field Name CPHONE CAMPD CDTRC
Length
10,0 6,2 6,0
Data Type
P P P
Key
K
Description
Customer Phone No Amount Paid Date received
1. Create a logical file CUSTML1 over CUSTM keyed on Payment date and select those records where address is Pune (Using COMP). 2. Create a logical file CUSTML2 over CUSTM and select the records with bill amount ranging from 1000.00 to 9999.99 (Using RANGE). 3. Create a logical file CUSTM3 over CUSTM and the records with status equal to (A or I) active/inactive (using VALUES). 4. Create a logical file CUSTML4 over CUSTM and rename the field COWED to AMTOD and update the data using the file. 5. Check all the logical files associated with CUSTM using command DSPDBR. 6. Create a Join logical file over CUSTM and CTRANS joined on CPHONE and arrange the duplicate records according to Amount Paid. 7. Create a field reference file and use its reference to create a physical file CUSTM1.identical to CUSTM 8. Add a physical file member to file CUSTM using command ADDPFM. Add data to it.
S R CHOWDARY