Tuesday, December 3, 2013

Day-4.

Logical Files:

 Overview:
This module enables the student to understand the concept of Logical File.

 Outline:

Topics covered,
    ·         Logical file creation
  •     Concept of Keyed & Sequential access
  •     Commands related to files
 Objective:

By the end of this module, the student should be able to:
  • 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.
  1.  Two or more logical files may share the same access path.
  2. Omit and select criteria may be specified in a logical file to process only the required physical file data.
  3. 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.
  4. One logical file with multiple record formats may process only the required physical file data.
  5. 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 file’s 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
3.     Field-level entries (optional)
4.     Key field level entries (optional)
5.     Select and omit-field level entries (optional)
6.     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  . . . . . . . . . . > MYDDS           Name, *PRV                   
   Library  . . . . . . . .> PB01U01D        Name, *LIBL, *CURLIB, *PRV   
 Source member  . . . . . . . . .   LSTUDENT        Name, *PRV, *SELECT          
 Source type  . . . . . . . . . .   LF              Name, *SAME, BAS, BASP...    
 Text ‘description’ . . . . . . .   ‘LOGICAL FILE FOR STUDENT’                 
                                                                                
                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                         Bottom
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   
 F24=More keys                              

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   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
Member LSTUDENT added tofile PN01U01D/MYDDS.       

AFTER TYPING  ‘IPLF’ AS SHOWN ABOVE USER GETS THE FOLLOWING PROMPT-



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

      ******************End of data ****************************************
                                                                               
                                                                                                                                                                                                                                               
                                                                                
 Prompt type . . .   LF      Sequence number . . .  “”””””                    
                                                                               
 Name                                            Data      Decimal                         
 Type        Name          Length       Type     Positions     Use          Functions                                                                     
                                                                               
F3=Exit   F4=Prompt   F5=Refresh  F11=Previous record   F12=Cancel F23=Select prompt   F24=More keys                                                                                                       

Enter reference file using ‘PFILE(FILE NAME)’ function key as well as record format name as shown below :
Columns . . . :    1  71            Edit                             PB01U01D/MYDDS
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 . . .   LF      Sequence number . . .  0001.00                    
 Name                                 Data      Decimal                        
 Type       Name         Length       Type     Positions     Use                
  R       SR                                                                   
 Functions      
PFILE(STUDENT)                                                              

F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                       

Enter key field of referred physical file :


Columns . . . :    1  71            Edit                            PB01U01D/MYDDS  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 ****************************************
                                                                                
                                                                               
                                                                                                                                                                                                                                            
Prompt type . . .   LF      Sequence number . . .  0002.00                    
 Name Type   Name         Length       Type     Decimal Positions     Use
     K       ROLL                                                                 
 Functions

F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                                                                                                                    

Press F3 and use option 14 to compile the above file and create object in PB01U01O and Runqry command for above logical file gives following output:

                                 Display Report                                
                                              Report width . . . . . :      39 
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  ********                                      
                                                                                                                                                                                                                                                                                                                     
                                                                               
                                                                       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:

Columns . . . :    1  71            Edit                            PB01U01D/MYDDS
 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   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       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.

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

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

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


Columns . . . :    1  71            Edit                            PB01U01S/MYDDS
SEU==>                                                                     LSTUDENT 
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   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               


HOW TO USE COLHDG & ‘TEXT’ K/W:

Columns . . . :    1  71            Edit                            PB01U01D/MYDDS

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   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                         © COPYRIGHT IBM CORP. 1981, 2002.   

 

OUTPUT OF COLHDG & TEXT KEYWORD :

Display Report                                
Report width . . . . . :      21 
 Position to line  . . . . .              Shift to column  . . . . . .         
 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  ********                                                                                                                      
                                                                                
                                                                                                                                        
                                                                                                                                                                
                                                                               
                                                                       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                            PB01U01D/MYDDS
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 . . .  0004.01                    
                                                                               
 Name                                 Data      Decimal                        
 Type       Name         Length       Type     Positions     Use               
  S         ROLL                                                                 
Functions                                                                     
COMP(GT 102)                                                                   

F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                       
 Above field shows the following output:

                                 Display Report                                
                                              Report width . . . . . :      21 
 Position to line  . . . . .              Shift to column  . . . . . .         
 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                            PB01U01D/MYDDS 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   F10=Cursor   F11=Toggle       
F16=Repeat find       F17=Repeat change          F24=More keys                
© COPYRIGHT IBM CORP. 1981, 2002.   
Note: Omit keyword is always used with DYNSLT to omit the value. This is logical file level keyword.

Output of above ‘omit’ keyword is as shown below see it using RUNQRY command on command line:




                                 Display Report                                
                                              Report width . . . . . :      21 
Position to line  . . . . .              Shift to column  . . . . . .         
Line   ....+....1....+....2.                                                           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                            PB01U01D/MYDDS
 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   F9=Retrieve   F10=Cursor   F11=Toggle        F16=Repeat find       F17=Repeat change          F24=More keys 
© COPYRIGHT IBM CORP. 1981, 2002.                                                                           
OUTPUT OF THIS COMPARISON IS


                                 Display Report                                
                                            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  ********                                       
                                                                               
                                                                               
                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                               
 Bottom    F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split           

Use of value keyword :

columns . . . :    1  71            Edit                            PB01U01D/MYDDS
 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   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                 


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



Display Report                                                                               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  ********                                      
                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                       Bottom  
 F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split           

No comments:

Post a Comment