Você está na página 1de 12

WORK WITH LOGICAL-FILE

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

WORK WITH LOGICAL-FILE


3. Field-level entries (optional) 4. Key field level entries (optional) 5. Select and omit-field level entries (optional)

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

F3=Exit F4=Prompt F24=More keys

F5=Refresh

F12=Cancel

Bottom F13=How to use this display

PRESS ENTER SO THAT YOU

GET THE FOLLOWING SCREEN

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

WORK WITH LOGICAL-FILE

Columns . . . : 1 71 Edit BIZLIB/QDDSSRC SEU==> LSTUDENT FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* ''''''' ******************End of data ****************************************

Prompt type . . . Name Type Functions

LF

Sequence number . . . Length

Type Decimal Positions Use

Data Name F5=Refresh

F3=Exit F4=Prompt F24=More keys

F11=Previous record

F12=Cancel F23=Select prompt

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

Sequence number . . . 0001.00 Data Decimal Length Type Positions

Use

File name using PFILE()


F5=Refresh F23=Select prompt F11=Previous record F24=More keys

Enter key field of referred physical file :

S R CHOWDARY

WORK 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 SR PFILE(STUDENT) 0002.00 K ROLL ****************** End of data ****************************************

Key Field Name

Prompt type . . . Name Type Name K ROLL Functions F3=Exit F4=Prompt F12=Cancel

LF

Sequence number . . . 0002.00 Length Type Decimal Positions

Use

Key field name


F5=Refresh F23=Select prompt F11=Previous record F24=More keys

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

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

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

WORK 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 RSTUDENT PFILE(STUDENT) 0002.00 A ROLL 0003.00 A SNAME 0004.00 A CORS 0005.00 A K ROLL ****************** End of data *******************************

F3=Exit F4=Prompt F16=Repeat find

F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F17=Repeat change F24=More keys COPYRIGHT IBM CORP. 1981, 2002.

Above logical file shows following output:

Use RUNQRY command on command prompt to see the output.


Position to line . . . . . Line ....+....1....+.... ROLL SNAME CORS 000001 101 sneha vv 000002 102 ramesh hh 000003 103 titu iii 000004 104 rahul AS400 ****** ******** End of report Display Report Report width . . . . . : Shift to column . . . . . . 19

********

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

Also you are able to define multiformat logical file as shown below:

Columns . . . : SEU==>

71

Edit

BIZLIB/QDDSSRC LSTUDENT

S R CHOWDARY

WORK WITH LOGICAL-FILE


FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 A R RS PFILE(STUDENT) 0002.00 A ROLL 0003.00 A SNAME 0004.00 A CORS 0005.00 A K ROLL 0005.01 * 0006.00 A R RCORS PFILE(CORS) 0007.00 A K CCD ****************** End of data ****************************************

F3=Exit F4=Prompt F16=Repeat find

F5=Refresh F9=Retrieve F17=Repeat change

F10=Cursor F11=Toggle F24=More keys

HOW TO USE COLHDG & TEXT K/W:

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 ****************************************

F3=Exit F4=Prompt F16=Repeat find

F5=Refresh F9=Retrieve F10=Cursor F11=Toggle F17=Repeat change F24=More keys COPYRIGHT IBM CORP. 1981, 2002.

OUTPUT OF COLHDG & TEXT KEYWORD :


Display Report

S R CHOWDARY

WORK WITH LOGICAL-FILE


Report width . . . . . : 21 Position to line . . . . . Line ....+....1....+....2. ROLL NO SNAME CORS 000001 101 sneha vv 000002 102 ramesh hh 000003 103 titu iii 000004 104 rahul AS400 ****** ******** End of report ********

Shift to column

. . . . . .

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

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

FOR SELECT K/W

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

F5=Refresh F23=Select prompt

Above field shows the following output:

S R CHOWDARY

WORK WITH LOGICAL-FILE


Display Report Report width . . . . . : Shift to column . . . . . .

21

Position to line . . . . . Line ....+....1....+....2. ROLL NO SNAME CORS 000001 103 titu iii 000002 104 rahul AS400 ****** ******** End of report

********

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

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.

F10=Cursor F11=Toggle F24=More keys

Note: Omit keyword is always used with DYNSLT to omit the value. This is logical file level keyword.

S R CHOWDARY

WORK WITH LOGICAL-FILE


Output of above omit keyword is as shown below see it using RUNQRY command on command line.
Display Report Report width . . . . . : 21 Shift to column . . . . . . ....+....1....+....2.

Position to line . . . . . Line ROLL NO SNAME CORS 000001 100 ABC AS400 000002 101 sneha vv ****** ******** End of report

********

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

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

F9=Retrieve F10=Cursor F24=More keys

F11=Toggle

S R CHOWDARY

WORK WITH LOGICAL-FILE

Position to line . . . . . Line ....+....1....+....2. ROLL NO SNAME CORS 000001 101 SNEHA VV 000002 103 titu iii ****** ******** End of report

Display Report Report width . . . . . : Shift to column . . . . . .

21

********

Bottom

F3=Exit

F12=Cancel

F19=Left

F20=Right

F21=Split

Use of value keyword :


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 0006.00 A O ROLL VALUES(102) 0007.00 A S ROLL COMP(GT 100) ****************** End of data ****************************************

F3=Exit F4=Prompt F16=Repeat find

F5=Refresh F9=Retrieve F17=Repeat change

F10=Cursor F11=Toggle F24=More keys

Output of this keyword is where roll number having value 102 gets omitted.

S R CHOWDARY

WORK WITH LOGICAL-FILE

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

Bottom F3=Exit F12=Cancel F19=Left F20=Right F21=Split

S R CHOWDARY

WORK WITH LOGICAL-FILE

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

Você também pode gostar