Tuesday, December 3, 2013

Day-3.

Physical Files:

 Overview:
This module enables the student to understand the concept of Physical and Logical File.
 Outline:
Topics covered,
·         Physical file creation
·         Logical file creation
  • Concept of Keyed and Sequential access
  • Commands related to files
  • Add records to physical file
 Objective:
By the end of this module, the student should be able to:
  • Create a Physical file
  • Create a Logical file
  • Understand the concept of Physical files.
  • Understand the part of Logical files.
  • Commands related to files.
  • Add records to physical file using STRDFU,UPDDTA.

Create a Physical File with or without a key field

 Introduction:
The AS/400 database, DB2/400 is part of the AS/400 operating system. The standard method of creating files is to define the specifications of the file using DDS(Data Description Specification). Of course DDS is used for other things on the AS/400 like defining display files and print files.

 Defining a physical file using DDS

An externally described file is one in which the record and field descriptions are defined outside of a program. The two types supported on the AS/400 are physical and logical files. Physical files are explained in this chapter and logical files in next.

Similar to disk files on non-data based computer system, physical files contain the actual data records. The attributes of the records may be data based-defined or program-defined. If they are database-defined, the field definitions are specified outside of a program. For program-defined files, the field attributes must be included in the program in the traditional RPG II way.

Physical files may be organized as non-keyed or keyed sequence files. The type of organization determines the access path followed when the file is processed.

A non-keyed file is similar to the standard sequential organization file in which keys are not specified. Records, which are processed in the order that they were loaded, may be read, written, and updated using sequential or relative record processing methods. Direct file organization is not supported on the AS/400. The processing methods unique to that file type, however, may be simulated for arrival of key-sequenced files.

A keyed sequence file is similar to the traditional indexed sequential file organization in which one or more fields may be specified as a key. Processing features unique to key sequence file are the following:

  1. Records may be accessed sequentially in key value order or randomly by the value of a key.
  2. Records may be accessed in arrival sequence order (ignores key value order).
  3. Composite keys may be defined by specifying more than one field within the body of a record. These fields need not be contiguous.
  4. Any field in the body of the record may be specified as a key field after the file is created. However, a logical file must be used to process the physical file by the new key(s).
  5. In addition to standard sequential and random processing, files may be read backward or accessed by a relative record number.
  6. The next record that is lower or higher than the specified key value may be accessed.
 The steps for building a physical file are the following:
  1. Design a record format based on some applications criteria.
  2. Write the code on a Data Description Specifications (DDS) form.
  3. Enter the DDS statements via the Source Entry Utility (SEU) and save.
  4. Compile, debug, and store the error-free physical file object format.
 Creation of physical file:
Notice that the first record has an "R" in position 17. This means that this line is specifying the record name. The "TEXT" is optional but helps to document the file. Shown in lab session.                                                          
After the line naming the record, each line describes a field. The field length and its data type follow the field name. Once you have entered the DDS source code, you must compile it. You do this by keying option 14 next to your member name on the PDM screen. Field length should not be greater than 10 characters.
Data Access:
You now have a database physical file, see Figure 1. This file has built into it the fields and their attributes. Let's modify this file definition to add key fields. If a physical file has key fields, programs can randomly access the records or read them sequentially in the order of the key fields.

The records are written to the file in arrival sequence. If you read the data by specifying keyed access, the records will read as though company number and customer number have sorted them. Also, your programs can randomly retrieve records.
 
Figure 1 - DDS for Physical File Without Key 
Columns . . . :    1  71            Edit                         PB01U01D/ MYDDS
 SEU==>                                                                 STUDENT
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0002.00      A          R RSTUD                                                
0003.00      A            ROLL           3S 0       COLHDG('ROLL NUMBER')      
0004.00      A            SNAME          5A         COLHDG('STUDENT NAME')     
0005.00      A            CCD            3S 0       COLHDG('COURSE CODE')      
0006.00      A            CORS           5A         COLHDG('COURSE NAME')      
0007.00      A            ADD            5A         COLHDG('ADDRESS')          
        ****************** End of data ****************************************
                                                                                                                                                 
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                
 
  
Figure 2 - DDS for Physical File With Key Fields
Columns . . . :    1  71            Edit                            PB01U01D/MYDDS
 SEU==>                                                                    STUDENT
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00                                             UNIQUE                     
0002.00      A          R RSTUD                                                
0003.00      A            ROLL           3S 0       COLHDG('ROLL NUMBER')      
0004.00      A            SNAME          5A         COLHDG('STUDENT NAME')     
0005.00      A            CCD            3S 0       COLHDG('COURSE CODE')      
0006.00      A            CORS           5A         COLHDG('COURSE NAME')      
0007.00      A            ADD            5A         COLHDG('ADDRESS')          
0008.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                
                                                                                                                                                                

Creating Physical File:

To create physical file, press F6 (source entry utility) write source file name, Library name, source member, source type as ‘PF’ and text description.

                       Start Source Entry Utility (STRSEU)                     
                                                                               
 Type choices, press Enter.                                                    
                                                                                
 Source file  . . . . . . . . . . > MYDDS         Name, *PRV                   
   Library  . . . . . . . . . . . >   PB01U01D    Name, *LIBL, *CURLIB, *PRV   
 Source member  . . . . . . . . .   STUDENT       Name, *PRV, *SELECT          
 Source type  . . . . . . . . . .   PF            Name, *SAME, BAS, BASP...    
 Text 'description' . . . . . . .   'STUDENT DETAILS'                          
                                                                                                                                   
                                                                        
                                                                         Bottom
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   
 F24=More keys                                                                  
                                                                               

HIT ENTER
Columns . . . :    1  71            Edit                         PB01U01D/MYDDS
 SEU==>                                                                 STUDENT
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
IPPF        *************** Beginning of data *************************************

                                                                                                      
                                                                                
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                 

NOTE : ‘IPPF’ IS INPUT PROMP FOR PHYSICAL FILE, USED TO DO FIELD ENTRIES IN PHYSICAL FILE.

Press enter Which gives you following prompt

Columns . . . :    1  71            Edit                        PB07U01O/MYRPG
 SEU==>                                                                   STUD4
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
'''''''                                                                         
        ****************** End of data ****************************************
                                                                                                   
                                                                               
                                                                               
 Prompt type . . .   PF      Sequence number . . .  '''''''                    
                                                                               
 Name                                     Data      Decimal                    
 Type       Name        Ref     Length    Type     Positions    Use            
                                                                                
 Functions                                                                     
                                                                               
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                       
                                                                                

THIS TABLE DESCRIBES YOU THE DETAILS OF ‘IPPF’ PROMPT.

HEADING
DESCRIPTION

Name type

Blank : Leave the field blank to indicate a Field Name.

R   : Type R in column 17 to indicate a Record Format Name. 


Name
Type a Record Format, Field, or Key Field Name in this position. The maximum length allowed is 10 characters,  beginning in column 19.    


Ref

Type R in this field to use the reference function to copy attributes of a previously defined   named field to the field you are now defining.                           

Length

Type a value to indicate the number of bytes in a Character field or the number of digits in a Numeric field.

Data Type

These are Data types which we use frequently:

S : Type S to indicate Zoned Decimal data.(For Numeric value)

F : Type F to indicate Floating Point data.

A : Type A to indicate Character data.

L : Type L to indicate Date data.

P : Type P to indicate Packed Decimal data.


Decimal Position

Type a value from 0 to 31 to indicate the number of decimal positions to the right of the decimal point within a Packed  Decimal, a Zoned Decimal, a Floating Point, or a Binary field.

USE

Type B or leave the field blank to indicate a field used for both  input and output.                                                 

Functions

Use Keywords like

COM Provides a comparison value (for     reference function only).       

RANGE   Provides a range of valid values  (for reference function only).   

Write your Record format as we discussed the sequence of PF in introduction.

Columns . . . :    1  71            Edit                         PB01U01D/MYDDS
 SEU==>                                                                 STUDENT
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00      A          R RSTUD                                                
        ****************** End of data ****************************************
                                                                               
 Prompt type . . .   PF      Sequence number . . .  0002.00                    
                                                                                
 Name                                     Data      Decimal                    
 Type       Name        Ref     Length    Type     Positions    Use   Functions          
  R           RSTUD                                                                 
                                                                  

                                                                               
 F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                       
Note:  Record format name is not having attributes like DATA TYPE and DECIMAL POSITION.

Hit enter and again write “IPPF’ to insert Field:

Now in second step you have to define fields having attributes field length, data type and decimal positions if field is numeric. Insert the define fields using same way.
While entering fields the values, which we provide for LENGTH, and DECIMAL POSITION are numeric must be RIGTHT align. To make it RIGHT ALIGN use right ‘Enter Key’ from numeric pad.


Columns . . . :    1  71            Edit                         PB01U01D/MYDDS
 SEU==>                                                                 STUDENT
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0002.00      A          R RSTUD                                                 
0003.00      A            ROLL           3S 0             
0004.00      A            SNAME          5A              
0005.00      A            CCD            3S 0      
0006.00      A            CORS           5A                
0007.00      A            ADD            5A        
0008.00      A          K ROLL                                                 
        ****************** End of data ****************************************
                                                                                
 Prompt type . . .   PF      Sequence number . . .  0003.00                    
                                                                               
 Name                                     Data      Decimal                    
 Type       Name        Ref     Length    Type     Positions    Use            
            ROLL                    3      S           0                       
 Functions                                                                      

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

 

PRESS F3


                                     Exit                                       
                                                                               
 Type choices, press Enter.                                                    
                                                                               
   Change/create member  . . . . . . .   Y            Y=Yes, N=No              
     Member  . . . . . . . . . . . . .   STUDENT        Name, F4 for list        
     File  . . . . . . . . . . . . . .   MYDDS         Name, F4 for list        
       Library . . . . . . . . . . . .     PB01U01D    Name                     
     Text  . . . . . . . . . . . . . .   PHYSICAL FILE FOR STUDENT               
                                                                               
     Resequence member . . . . . . . .   N            Y=Yes, N=No              
       Start . . . . . . . . . . . . .   0001.00      0000.01-9999.99          
       Increment . . . . . . . . . . .   01.00        00.01-99.99              
                                                                                
   Print member  . . . . . . . . . . .   N            Y=Yes, N=No              
                                                                               
   Return to editing . . . . . . . . .   N            Y=Yes, N=No              
                                                                               
   Go to member list . . . . . . . . .   N            Y=Yes, N=No              
                                                                                

   

Hit Enter  

                                                  
                           Work with Members Using PDM                 S653278B
                                                                                
 File  . . . . . .   MYDDS                                                      
   Library . . . .     PB01U01D                Position to  . . . . .             
                                                                                
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                                
 Opt  Member      Type        Text                                             
      STUDENT     PF          PHYSICAL FILE                                    
                                                                                                                       
                                                                               
                                                                               
                                                                         Bottom
 Parameters or command                                                         
 ===>                                                                          
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    

To compile PF use command CRTPF or opt 14 against PF that create object of PF (as shown below).

                           Work with Members Using PDM                 S653278B
                                                                               
 File  . . . . . .   MYDDS                                                      
   Library . . . .     PB01U01D                Position to  . . . . .              
                                                                               
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                               
 Opt  Member      Type        Text                                             
 
 14   STUDENT        PF          PHYSICAL FILE                                    
                                                                                  
                                                                               
                                                                                
                                                                         Bottom
 Parameters or command                                                         
 ===>                                                                           
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    

After writing 14 over Opt and press F4 that is same as CRTPF on command line with F4.

                          Create Physical File (CRTPF)                         
                                                                               
 Type choices, press Enter.                                                     
                                                                               
 File . . . . . . . . . . . . . . > STUDENT          Name                         
   Library  . . . . . . . . . . . >   PB01U01D       Name, *CURLIB                
 Source file  . . . . . . . . . . > MYDDS            Name                         
   Library  . . . . . . . . . . . >   PB01U01O       Name, *LIBL, *CURLIB         
 Source member  . . . . . . . . . > STUDENT          Name, *FILE                  
 Record length, if no DDS . . . .                    Number                       
 Generation severity level  . . .   20               0-30                         
 Flagging severity level  . . . .   0                0-30                          
 File type  . . . . . . . . . . .   *DATA           *DATA, *SRC                  
 Member, if desired . . . . . . .   *FILE            Name, *FILE, *NONE           
 Text 'description' . . . . . . .   *SRCMBRTXT                                  
                                                                               
                                                                                                                
                                                                               
                                                                        More...
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   
 F24=More keys                                                                 

PRESS ENTER WHICH CREATES PHYSICAL FILES OBJECT. NOW TO UPDATE PF, WRITE ‘UPDDTA <FILE NAME> ‘ command on command line.

                           Work with Members Using PDM                 S653278B
                                                                               
 File  . . . . . .   MYDDS                                                       
   Library . . . .     PB01U01D                Position to  . . . . .             
                                                                               
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                               
 Opt  Member      Type        Text                                             
      STUDENT     PF          PHYSICAL FILE                                    

                                                                               
                                                                                
                                                                               
                                                                         Bottom
 Parameters or command                                                          
 ===> UPDDTA                                                                   
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    
                                                                                   
     
Press F4 to see Parameter for UPDDTA command.

                     Update Data with Temp Program (UPDDTA)                    
                                                                                
 Type choices, press Enter.                                                    
                                                                               
 Data base file . . . . . . . . .   STUDENT          Name                         
   Library  . . . . . . . . . . .     PB01U01O       Name, *LIBL, *CURLIB         
 Member . . . . . . . . . . . . .   *FIRST        Name, *FIRST                 
                                                                                
                                                                                                                      
                                                                               
                                                                               
                                                                         Bottom
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   
 F24=More keys                                                                  
                    
Hit Enter. Add records to these fields.                                                           

WORK WITH DATA IN A FILE                       Mode . . . . :   ENTRY         
 Format . . . . :   RSTUD                       File . . . . :   STUD          
                                                                               
 ROLL:                                                                         
 SNAME:                                                                        
 CCD:                                                                          
 CORS:                                                                         
 ADD:                                                                          
                                                                                                                                                           
                                                                                
 F3=Exit                 F5=Refresh               F6=Select format             
 F9=Insert               F10=Entry                F11=Change                   
                                          (C) COPYRIGHT IBM CORP. 1980, 2002.                                                                              

INSERT DATA AS PER REQUIREMENT. PRESS F3 TO EXIT FROM FILE.


                                End Data Entry                                 
                                                                                
   Number of records processed                                                 

No of records added
 
                                                                               
     Added  . . . . . :           3                                             
     Changed  . . . . :           0                                            
     Deleted  . . . . :           0                                            
                                                                                
                                                                               
                                                                               
                                                                                
 Type choice, press Enter.                                                     
                                                                               
   End data entry  . . . . . . .    Y           Y=Yes,  N=No                   
                                                                                                                      
                                                                                
                                                                               
 F3=Exit       F12=Cancel                                                      


Press enter. After insertion of data do not compile the file which delete your data. Use ‘RUNQRY *N <FILENAME>’ to run or to see the content of physical file.

  
                           Work with Members Using PDM                 S653278B
                                                                                
 File  . . . . . .   MYDDS                                                     
   Library . . . .     PB07U01D             Position to  . . . . .             
                                                                                
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                               
 Opt  Member      Type        Text                                             
      STUDENT     PF          STUDENT DETAILS                                  

               
                                                        More...
 Parameters or command                                                         
 ===> RUNQRY *N STUDENT
                                                        
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    
                                                                               

Press enter

                                 Display Report                                
                                              Report width . . . . . :      60 
 Position to line  . . . . .              Shift to column  . . . . . .         
 Line   ....+....1....+....2....+....3....+....4....+....5....+....6           
        ROLL NUMBER  STUDENT NAME  COURSE CODE  COURSE NAME  ADDRESS           
 000001     101         RAHUL          100         VB         PUNE             
 000002     102         TITU           101         AS         MUM              
 ****** ********  End of report  ********                                      
                                                                               
                                                                                
                                                                               
                                                                                                                                
                                                                               
                                                                                                   
                                                                               
                                                                       Bottom  
 F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split           
                                                                               

KEYWORDS:
A) File level keywords:
Following are the File Level Keywords:
            UNIQUE
            FIFO (First In First Out)
            LIFO (Last In First Out)
            FCFO (First Change First Out)

1)    UNIQUE: The "UNIQUE" record at the beginning of the source is used if you want the AS/400 to insist on having no records with duplicate keys. This is optional. At the end of the source code, there are two lines with "K" in position 17. These lines define the key fields.
2)    FIFO LIFO FCFO: These keywords are used with the duplicate entries to specify the order. 



Columns . . .:    1  71            Edit                            PB01U01D/MYDDS
 SEU==>                                                                    STUDENT
 FMT PF ...A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0000.01                                           UNIQUE                     
0001.00      A          R RSTUD                                                
0002.00      A            ROLL           3S 0                                  
0003.00      A            SNAME          5A                                     
0004.00      A            CORS           5A                                    
0005.00      A            ADD            5A                                    
0006.00      A            CITY           5A                                     
0007.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                
            LIKE ‘UNIQUE’ KEYWORD USE FIFO, LIFO AND FCFO KEYWORDS.
Record Level Keywords:
FORMAT (Format) keyword for physical and logical files
Use this record-level keyword to specify that this record format is to share the field specifications for a
previously defined record format. The name of the record format you are defining must be the name of the previously defined record format.

The format of the keyword is:
FORMAT([library-name/]database-file-name)
The database-file-name parameter is required. It is the name of the physical or logical file from which the previously defined record format is taken.

Create new physical file ‘student1’ and define only record format name with FORMAT keyword having filename which is to be reffered.

Columns . . .:    1  71            Edit                            PB01U01D/MYDDS
 SEU==>                                                                    STUDENT1
 FMT PF ...A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00      A          R RSTUD                   FORMAT(STUDENT)                              
        ****************** End of data **************************************                                            
                                                                               
                                                                               
                                                                                
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                 
                                                                               
COMPILE THIS FILE AND USE RUNQUERY OPTION TO RUN THE FILE.


The name of this record format (RSTUD) must be the same as the name of the record format in STUDENT. Like FORMAT ‘TEXT’ is also a record level keyword use as follows:

Columns . . .:    1  71            Edit                            PB01U01S/MYDDS
 SEU==>                                                                    STUDENT
 FMT PF ...A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00      A          R RSTUD                   TEXT(‘STUDENT DETAILS’)                             
0002.00      A            ROLL           3S 0                                  
0003.00      A            SNAME          5A                                    
0004.00      A            CORS           5A                                    
0005.00      A            ADD            5A                                    
0006.00      A            CITY           5A                                    
0007.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                

The name of this record format (RSTUD) must be the same as the name of the record format in STUDENT.

Field Level Keywords:

ALIAS (Alternative Name) keyword for physical and logical files
 Use this field-level keyword to specify an alternative name for a field. When the program is compiled, the alternative name is brought into the program instead of the DDS field name.
The format of the keyword is:
ALIAS (alternative-name)
 The alternative name must be different from all other alternative names and from all DDS field names in the record format. If a duplicate is found, an error message appears on the field name or alternative name. When you refer to a field that has the ALIAS keyword, the ALIAS keyword is copied in unless the ALIAS keyword is explicitly specified on the referencing field.

Example:

The following example shows how to specify the ALIAS keyword.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A      FIELDA         25A             ALIAS(STUDENT NAME)

In the example, the alternative name for FIELDA is STUDENT NAME.

COLHDG (Column Heading) keyword for physical and logical files:
Use this field-level keyword to specify column headings used as a label for this field by text management, the query utility, the data file utility (DFU), and the screen design aid (SDA).
The format of the keyword is:
COLHDG (’line-1’ [’line-2’ [’line-3’]])

A maximum of three lines of 20 characters each is allowed. Each line of the column heading must be
enclosed in apostrophes. Use double apostrophes (’ ’) to specify apostrophes within column headings.
Use one or more blanks to separate the first column heading line from the second and the second from
the third.

For example, COLHDG (’Order’ ’Date’) is equivalent to TEXT (’Order Date’).

Example:
The following example shows how to specify the COLHDG keyword for a physical file.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00150A        ROLL      5 0            COLHDG(’ROLL’ ’NUMBER’)
00160A        SNAME  20              COLHDG(’Student’s Name’)

TEXT : This is record level as well as field level keyword which describes your field.
 Example:
The following example shows how to specify the COLHDG keyword for a physical file.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00150A        ROLL      5 0            TEXT(’ROLL NUMBER’)
00160A        SNAME  20              TEXT(‘Student’s Name’)

 CHECK
Use this field-level keyword to specify validity checking in display files.
 The rules for specifying this keyword in a physical or logical file are similar to those for a display file.
However, only the following codes are allowed in physical or logical files:

Code Meaning
AB         Allow blank
ME        Mandatory enter
MF        Mandatory fill
M10      IBM* Modulus 10 self-check algorithm
M10F    IBM® Modulus 10 self-check algorithm
M11      IBM Modulus 11 self-check algorithm
M11F    IBM Modulus 11 self-check algorithm
VN         Validate name
VNE       Validate name extended

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00150A        ROLL      5 0            CHECK(AB)
00160A        SNAME  20              CHECK(MF)
Above example shows that roll number may be blank and student name is mandatory.
You cannot specify the CHECK(AB), CHECK(VN), CHECK(VNE), CHECK(M10), CHECK(M11),
CHECK(M10F), or CHECK(M11F) keywords on a floating-point field (F in position 35). You cannot specify the CHECK keyword on a hexadecimal field (H in position 35). Do not specify the CHECK keyword on a date, time, or timestamp field (L, T, or Z in position 35).


DESCEND (Descend) keyword for physical
Use this key field-level keyword to specify that the values of this character, hexadecimal, or numeric key field are retrieved in descending sequence. The default is ascending sequence. See “SIGNED (Signed) keyword for physical and logical files” on page 69 for an example of data sorted using the DESCEND keyword.

This keyword has no parameters.
 Example:
The following example shows how to specify the DESCEND keyword for a logical file.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A KITEM
00020A KBALDUE DESCEND
COMP (Comparison) keyword for physical and logical files
Use this field-level keyword to specify validity checking for the field you are defining when it is referred to later during display file creation. COMP is equivalent to CMP.

The format of the keyword is:
COMP (relational-operator value) At the select/omit-field level, the format of the keyword is:

COMP (relational-operator field-name)
Valid relational operators are:
Relational Operator
Meaning
EQ  Equal to
NE  Not equal to
LT  Less than
NL  Not less than
GT  Greater than
NG  Not greater than
LE   Less than or equal to
GE  Greater than or equal to

Specify the value parameter at either the field level or the select/omit field level. Specify the field name
parameter only at the select/omit field level.
The RANGE Keyword
The RANGE keyword validates that the data in a field value is equal or greater than the lower value and less than or equal to the higher value specified in the RANGE key word.

The format of the keyword is:
Range (low-value   high –value)
When the related field is defined as character , the low and high values must both be enclosed in single quotes. The quotes are omitted for numeric fields. Figure details two examples of the RANGE keyword.
The VALUES Keyword
The VALUES keywords validates that a field value is equal to one of the values included in the specified list. It is similar to the COMP keyword in that a relational test is made. However the VALUES keyword only performs an equal test on a list of values, whereas the COMP keyword may include any of the relational tests, but only for one value.

The format of the keyword is
VALUES (value-1[value-2….[value-1001])

One hundred values may be specified, each separated by at least one blank. A VALUES keyword specified with character fields must have each value in the list enclosed in single quotes. Numeric values are specified without quotes Identical to any relational comparison function, the value list must be the same type as the related field. Figure shows two coding examples of the VALUES keyword.

PHYSICAL FILE MAINTENANCE COMMANDS


Command
Description
Usage
CHGPF
Change physical file
Supports changes in the attributes of a physical file without requiring its recreation with the CRTPF command. The data in the physical file is not lost when CHGPF is executed.
CLRPFM
Clear physical file member
Clears a physical file member of all data records with-out deleting the file’s structure.

CPYF
Copy file
Copies the data stored in a physical file to an output device or another physical file. Either all of the records or only selected records may be copied. A variety of selection criteria may be specified such as a key or a relative record number range. When output is to a printer, either character or hexadecimal format may be specified. For readability, however, hexadecimal format is necessary if packed numeric values are stored in one or more fields of the record format.
DLTF
Delete File
Deletes the physical file’s object and any data stored in the file. A file cannot be deleted if a logical file has been created over it or if the file is in use.

DSPPFM
Display Physical File Member
Displays the field values in the records stored in a physical file. Records are displayed in arrival sequence even if the file was created as keyed. A character or hexadecimal display of the record values may be specified. Other than printing the current display with the values may be specified. Other than printing the current display with the Print key, printer output is not supported.

Remove Member
Removes the specified member from the physical file and deletes all of the data stores in the member.

DSPPFD
Display Physical file Description


Entering the command on the command line of an AS/400 display and pressing F4 may execute any of these CL commands. One or more prompt screens will display enabling the programmers to enter command specific data.

Questions:


Q1.       What is an externally defined file? What two types are supported on the AS/400?
            ___________________________________________________________________________
            ___________________________________________________________________________

Q2 .      Explain how any field included in the file in an ascending or descending order may process a physical file. “Sorting” is not an acceptable answer.
            ___________________________________________________________________________
            ___________________________________________________________________________

Q3.       Name the steps followed for building a physical file.
            ___________________________________________________________________________
            ___________________________________________________________________________

Q4.       How many record formats may be included in a physical file?
            ___________________________________________________________________________
            ___________________________________________________________________________

Q5.       What is the function of the following physical file keywords?
            ___________________________________________________________________________
            ___________________________________________________________________________

COLHDG           EDTWRD           REFLD
DESCEND          LIFO                 TEXT
EDTCDE            REF                   UNIQUE

Q6 What CL command is used to display he attributes of a physical file? Name the CL command needed to display the field attributes of a physical file.
 ________________________________________________________________________
            ___________________________________________________________________________

Q7 Explain the function of he following physical file maintenance commands:
CHGPF  CLRPFM            CPYF
DSPPFM            RMVM   DLTF

Q8 How many default members are assigned when a physical file is created without changing any parameters? How is a file created to support more than one member?
            ___________________________________________________________________________
            ___________________________________________________________________________


Q9. By what methods may data be loaded to a physical file?
            ___________________________________________________________________________
            ___________________________________________________________________________









      

No comments:

Post a Comment