Top Banner
AS400 Introduction In AS400, AS stands for "Application System”. It is multiuser, multitasking and very secure system and hence is used for the industry which requires sensitive data to be stored and processed simultaneously. It has integrated the DB2 database management system, menu-driven interfaces, multi-user support, security, communications, client–server and web-based applications. It is best suited for mid-level industry and hence is used in pharmaceutical industry, banking, malls, hospital administration, manufacturing, distribution industry, financial organization, e-commerce etc. The AS/400 (Application System/400) was first introduced by IBM on June 21st, 1988 and later renamed to as eServer iSeries in 2000, then in 2006, it was renamed as System i . In 2008 System i got unified with System p to become Power system. The operating system for AS400 also got renamed with the rebranding. Initially, it was OS/400 then i5/OSand then iBM i (Power system). OS/400 Version 4, introduced a feature LPAR (Logical PARtitioning) which facilitates running multiple operating systems simultaneously on one IBM System i unit ensuring that one OS doesn’t interfere other’s system resources/memory. Programming languages available for the AS/400 include RPG, assembly language, C, C+ +, Pascal, Java,Perl, Smalltalk, COBOL, SQL, BASIC, PHP, Pyth on.
31

Basics of AS/400

Jan 19, 2016

Download

Documents

talam2

From this document we can easily have the broad concept of AS/400 Server.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Basics of AS/400

 AS400 Introduction

         In AS400, AS stands for "Application System”.

         It is multiuser, multitasking and very secure system and hence is used for the industry

which requires sensitive data to be stored and processed simultaneously.

         It has integrated the DB2 database management system, menu-driven interfaces, multi-

user support, security, communications, client–server and web-based applications.

         It is best suited for mid-level industry and hence is used in pharmaceutical industry,

banking, malls, hospital administration, manufacturing, distribution industry, financial

organization, e-commerce etc.

         The AS/400 (Application System/400) was first introduced by IBM on June 21st, 1988

and later renamed to as eServer iSeries  in 2000, then in 2006, it was renamed as System

i . In 2008 System i got unified with System p to become Power system.

         The operating system for AS400 also got renamed with the rebranding. Initially, it

was OS/400 then i5/OSand then iBM i (Power system).

         OS/400 Version 4, introduced a feature LPAR (Logical PARtitioning) which  facilitates

running multiple operating systems simultaneously on one IBM System i unit ensuring that

one OS doesn’t interfere other’s system resources/memory.

         Programming languages available for the AS/400 include RPG, assembly language, C, C+

+, Pascal, Java,Perl, Smalltalk, COBOL, SQL, BASIC, PHP, Python.

         AS400 is based on Layered machine architecture. It enables user to move to new hardware

technology at any time, without disrupting their application programs.

         It has Object orientation i.e. everything that can be stored or retrieved on the system is

known as an“objects”. AS400 can recognize only the object types that have been defined

for it. It cannot identify any unknown objects that don’t seem to be known. It adds extra

security to the system.

         It provides contiguous memory between main storage and disk storage. It provides

authority to add any disk space so that use.

         Another feature of AS400 is that it is very secure system making it to store sensitive data.

It incorporates security at various levels. Any user can be limited to access/process only

particular information on thesystem.

Page 2: Basics of AS/400

 Library   

         When we execute a command or call a program, the AS/400 must know where to find

the command or program and the answer is library.

         A Library is a collection of objects.

         QSYS is the only library that contains other library.

         A library contain the object name, type, and the address

         QSYS is the root library where the entire user defined/ system defined library is created.

         System library is the library that contains the objects that was created at the time OS400

was installed.

         System supplied libraries begin with the letter "Q" or "#".

         When you logon the first library to be load is QSYS. The system library is loaded at the

first time.

 

 Library list types:         System library: All IBM supplied library e.g. QSYS, QHLPSYS, QUSRSYS…

         Product Library: Whenever Ibm product is used it is added to the library automatically

and is removed itself when    the job completes.

         Current Library: Current library is the working library i.e. all the work done by you is

stored in current library. If you want that all the things done by you should be stored in

your personal library ‘AMINEM’ , then just change the current library as your personal

library.

To change current library to your personal library AMINEM: CHGCURLIB    AMINEM

         User Library: Non-IBM supplied i.e. created by the user.

 

Page 3: Basics of AS/400

 

 Related commands: 

      I.        Display Library List (DSPLIBL) 

To display all types of libraries, we can use the command:

In the below snapshot we can see different types of library in the library list

e.g. SYS(system), CUR(current), USR(user) library.

                              Display Library List                             

                                                             System:   USALID09

                                                                               

                                                                               

 Type options, press Enter.                                                     

   5=Display objects in library                                                

                                                                               

                            ASP                                                 

 Opt  Library     Type      Device      Text                                   

      QSYS        SYS                   System Library                         

      QSYS2       SYS                   System Library for CPI's               

      QHLPSYS     SYS                                                          

      QUSRSYS     SYS                   System Library for Users               

      AMINEM      CUR                                                          

      QGPL        USR                   General Purpose Library                

      QTEMP       USR                                                          

      LOAD        USR                   Future Three - LOAD Procedure & Update 

                                                                        More...

 F3=Exit   F12=Cancel   F17=Top   F18=Bottom                                   

 

  

    II.        Create Library (CRTLIB) 

 

To create library the command is: CRTLIB  IROBO1  Press F4

 

Page 4: Basics of AS/400

   

Type choices, press Enter.     

       Library . . . . . . . . . . . . IROBO1 Name 

       Library type . . . . . . . . . . *TEST (*PROD, *TEST)

       Text 'description' . . . . . . . THIS IS IROBO'S TEST LIBRARY 

       Bottom 

       F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel 

       F13=How to use this display F24=More keys 

 

Library type (TYPE)

 

  *PROD

Database files in production libraries cannot be opened for updating if a user is in debug mode and 

he requested that production libraries be protected.

                                            A user can protect  all  database files   in  production  libraries from 

updates  by   specifying  *NO  for   the  Update  production files   (UPDPROD)  parameter  on   the  Start 

Debug (STRDBG) command to begin testing. However, this protection does not prevent the program 

from deleting database files or from changing other objects (such as data areas) in the library.

 

  *TEST

This   is  a  test   library.  All  objects   in  a   test   library  can be updated during testing,  even  if  special 

protection is requested for production libraries.

 

 

 

   III.        Display library (DSPLIB) 

DSPLIB IROBO1

Page 5: Basics of AS/400

 

It   gives   you   the   information   of   all   objects   that   resides   in   the   library   with its            size.              

 

                                Display Library                                 

                                                                               

 Library  . . . . . . :   IROBO1          Number of objects  . :   8           

 Type . . . . . . . . :   PROD            Library ASP number . :   1           

 Create authority . . :   *EXCLUDE        Library ASP device . :   *SYSBAS     

                                                                               

 Type options, press Enter.                                                     

   5=Display full attributes   8=Display service attributes                    

                                                                               

 Opt  Object      Type      Attribute               Size  Text                 

      PRINT1PGM   *PGM      RPGLE                 131072  rpgle program for pri

      ACCOUNT     *FILE     PF                     49152  ACCOUNT RELATED INFOR

      PRINT1      *FILE     PRTF                    4096  PRINTER DDS RLU GENER

      QCLSRC      *FILE     PF                      8192  Sources CL-Programs  

      QDDSSRC     *FILE     PF                      8192  DDS-Sourcen          

      QRPGLESRC   *FILE     PF                     69632                       

      QRPGLESRC2  *FILE     PF                     65536                       

      QRPGSRC     *FILE     PF                      8192  SOURCE PHYSICAL FILE 

                                                                               

                                                                                

                                                                               

                                                                         Bottom

 F3=Exit   F12=Cancel   F17=Top   F18=Bottom                                    

 

 

 

 

  IV.        Edit Library List (EDTLIBL) 

You can add your personal library to any position just update the sequence no. “0” with the required where you want your library to be and the corresponding library name.

 

                         Edit Library List                                                      System:   PUB1

Page 6: Basics of AS/400

Type new/changed information, press Enter. Sequence                   Sequence                  SequenceNumber   Library           Number   Library          Number   Library 0                        150                        30010    GAMES400            160                        31020    QGPL                170                        32030    QTEMP               180                        33040                        190                        34050                        200                        35060                        210                        36070                        220                        37080                        230                        38090                        240                        390

 

 

 

   V.        Add Library List Entry (ADDLIBLE) ADDLIBLE LIB(IROBO1) POSITION(*First)

 

It adds your personal library at the first position in the library list.

  

  VI.        Work With Libraries Using PDM (WRKLIBPDM)

Page 7: Basics of AS/400

  Sourcephysical file

        Source physical file is a filewhich contains the sources of different types of objects.

        Command used is CRTSRCPF.CRTSRCPFFILE(IROBO1/QRPGSRC) RCDLEN(112) TEXT('SOURCE PHYSICAL FILE’)

        There can be up to 32767 members. 

        Source physical file is anobject. But the source member is not an object. When we

compile the member, theobject is created for that source.

 

To see all thesource members of a source physical file, the command used is WRKMBRPDM.                           Work with MembersUsing PDM                 PUB1                                                                                    File  .. . . . .   QRPGLESRC                                                    Library . . . .     IROBO1               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                                                   ACCOUNT     PF         ACCOUNT RELATED INFORMATION                            PRINT1      PRTF       PRINTER DDS RLU GENERATED                              PRINT1PGM   RPGLE      rpgle program for print1                                                                                                                                                                                       

                                                                         Bottom Parameters or

command                                                          ===>

_______________________________________________________________________________________________________________________________________________________

_                                                                          F3=Exit          F4=Prompt             F5=Refresh            F6=Create         F9=Retrieve      F10=Command entry     F23=More options      F24=More

keys    

                                                                               

To add source ofany type of object in a source physical file we use the

command WRKMBRPDMand then F6.

 

Structure of the source physical file:

        12                                                80                                                           12

Page 8: Basics of AS/400

Serial no./Date Source of the member

 

Comment

 

 

If you want tocheck the structure do the runqry to check it:

RUNQRY QRYFILE ((QRPGLESRC *LAST))

 

 

                                                         Display

Report                                  

                                                                                               

 Position to line  . . . . .                                                               Shift to

column

 Line  ....

+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...1

          SRCSEQ    SRCDAT  SRCDTA                                                                  

      

 000001    1.00   121,019        FPRINT1    o   E             PRINTEROFLIND(*IN90)                  

   

 000002    2.00   121,019        FACCOUNT   IF  E           K

DISK                                      

 000003    3.00   121,019        C                   Z-ADD     *ZEROS        COUNT             2

0       

 000004    4.00   121,019        C                  WRITE     HEADER1                               

    

 000005    5.00   121,019        C                   WRITE     HEADER2                              

     

 000006    6.00   121,019        C                   READ      REC1                                 

  80 

 000007    7.00   121,019        C                   DOW       *IN80=*OFF                           

     

 000008    8.00   121,019        C                   WRITE     DETAIL                               

90   

 000009    9.00   121,019        C  90              WRITE     HEADER2                               

    

 000010   10.00   121,019        C                   EVAL      COUNT=COUNT+1                        

     

 000011   11.00   121,019        C                   READ     REC1                                  

80 

 000012   12.00   121,019        C                   ENDDO                                          

     

 000013   13.00   121,019        C                   EVAL      TOTAL=COUNT                          

     

Page 9: Basics of AS/400

 000014   14.00   121,019        C                   WRITE     FOOTER                               

     

 000015   15.00   121,019        C                  SETON                                        LR 

    

 ****** ********  End of

report ********                                                                 

 

System defaultlength of Source physical file92

Recommendedlength of Source physical file112

**Note: If we are copying thesource code from one source file of length 112, we must assure that

the targetsource file must be of length 112, else the source code will be truncated.

 

  Other than WRKMBRPDM, we can get the detail of Source physical fileby command DSPFD.

 

  Related commands I.       Display FileDescription (DSPFD) DSPFD   IROBO1/QRPGLESRC 

The command given information:

 

  It is a source physical file in library IROBO1.

  It’s creation date.

  Detail of each and every member(ACCOUNT,PRINT1,PRINTPGM) as in abovesnapshot.

  File Level Identifier: It is actually the timestamp that relate to creation date/time ofsource

file.

  Member Level Identifier: It is actually the timestamp that relate to creation date/time

ofMembers.

                                             File/Member Level Identifiers are used by operations such as

RSTOBJ tohelp avoid restoring files that are the wrong versions.

Page 10: Basics of AS/400

  Record FormatLevel Identifiers:  are hashes ofattributes of all of the fields in the format.

Attributes such as lengths andbuffer positions are hashed in order to generate a nearly

unique value.

                                                A difference betweenFormat Level Identifiers in a program

and in a file will result in a "levelcheck" exception when the program attempts to open

the file.

  Initial no. of records: Initially what is the no. of records(Here it is 10000)

  Increment no. of record: Indicates, what should be the number of times the increment

willhappen.(Here it is 1000)

  Maximum no. of increment: Indicates, what should be the increment factor by which

the  record will increase.(Here it is 499)

  Record capacity: Hence, on the basis of above three, themaximum no. of record could be

10000+499*1000=509000 i.e. given as recordcapacity below.

  Current number of records: Current no.of record for each member.

  No. of format=01

  Total record length : 112

  In the bottom summary of all members. 

 

                                                       Display Spooled File

 File  .. . . . :   QPDSPFD                                                

 Control . . . . .                                                          

 Find  .. . . . .                                                          

 *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+.

    12/31/12                Display File Description                        

  DSPFD Command Input                                                       

    File . . . . . . . . . . . . . . . . . . . : FILE       QRPGLESRC      

      Library . . . . . . . . . . . . . . . . .:            *LIBL          

  File Description Header                                                   

    File . . . . . . . . . . . . . . . . . . . : FILE       QRPGLESRC      

    Library . . . . . . . . . . . . . . . . . .:            IROBO1         

    Type of file  . . . . . . . . . . . . . . . :            Physical       

    File type . . . . . . . . . . . . . . . . .: FILETYPE   *SRC           

Page 11: Basics of AS/400

    Auxiliary storage pool ID . . . . . . . . .:            00001          

  Data Base File Attributes                                                 

    Externally described file . . . . . . . . .:            Yes            

    File level identifier . . . . . . . . . . .:            1121019191538  

    Creation date . . . . . . . . . . . . . . .:            10/19/12       

 

    Maximum members . . . . . . . . . . . . . .: MAXMBRS    *NOMAX        

    Number of constraints . . . . . . . . . . .:                0         

    Number of triggers  . . . . . . . . . . . . :                0         

    Number of members . . . . . . . . . . . . .:                3         

    Member size                                   SIZE                     

      Initial number of records . . . . . . . .:                 10000    

      Increment number of records . . . . . . .:             1000         

      Maximum number of increments  . . . . . . :              499         

    Record capacity . . . . . . . . . . . . . .:                509000    

    Coded character set identifier  . . . . . . : CCSID        273         

        Initial number of records . . . . . . .:                 10000     

        Increment number of records . . . . . .:             1000         

        Maximum number of increments  . . . . . :              499         

      Current number of increments  . . . . . . :                     0    

      Record capacity . . . . . . . . . . . . .:                509000    

      Current number of records . . . . . . . .:                     8    

      Number of deleted records . . . . . . . .:                     0    

      Starting journal receiver for apply . . .:                                    

 

    Member . . . . . . . . . . . . . . . . . . : MBR        PRINT1                  

      Member level identifier . . . . . . . . .:            1121019191550           

      Member creation date  . . . . . . . . . . :            10/19/12                

      Text 'description'  . . . . . . . . . . . : TEXT       PRINTER DDS RLU GENERATED

      Expiration date for member  . . . . . . . : EXPDATE    *NONE                   

      Member size                                 SIZE                               

        Initial number of records . . . . . . .:                 10000              

        Increment number of records . . . . . .:             1000                   

        Maximum number of increments  . . . . . :              499                 

      Current number of increments  . . . . . . :                     0    

      Record capacity . . . . . . . . . . . . .:                509000    

      Current number of records . . . . . . . .:                    66    

      Number of deleted records . . . . . . . .:                     0    

 

  Record Format List                                                                  

                         Record  Format Level                                         

   Format      Fields   Length  Identifier                                           

   QRPGLESRC         3     112  2A4BA13FFF687                                        

     Text . . . . . . . . . . . . . . . . . . .:                                     

   Total number of formats  . . . . . . . . . . :           1                         

   Total number of fields . . . . . . . . . . .:           3                          

Page 12: Basics of AS/400

   Total record length  . . . . . . . . . . . . :         112                         

  Member List                                                                         

                               SourceCreation    Last Change                  Deleted

   Member           Size        Type Date       Date     Time     Records    Records

   ACCOUNT                8192 PF     10/19/12 10/19/12 19:15:50          8          0

     Text: ACCOUNT RELATED INFORMATION                                                

   PRINT1                16384 PRTF   10/19/12 10/19/12 19:17:53         66          0

     Text: PRINTER DDS RLU GENERATED                                            

   PRINT1PGM              8192 RPGLE  10/19/12 10/19/12 19:15:50         15          0

     Text: rpgle program for print1                                                  

   Total number of members  . . . . . . . . . :                 3                     

   Total number of members not available  . . :                 0                     

   Total records  . . . . . . . . . . . . . . :                89                     

   Total deleted records  . . . . . . . . . . :                 0                     

   Total of member

sizes  . . . . . . . . . . :             32768                                                                                                           

 

 

Note: The information can be filtered based on the TYPE

attribute:           *MBR,*ACCPTH,*MBRLIST,*RCDFMT,*MBR.     

          

DSPFD FILE(IROBO1/QRPGLESRC) TYPE(*MBRLIST)

 

 

                                                       Display Spooled

File          

 File  . . . . .

:  QPDSPFD                                                          

 Control . .. .

.                                                                     

 Find  . . . . .

.                                                                    

 *...

+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+.

   12/31/12                DisplayFile

Description                                  

  DSPFDCommand

Input                                                                 

   File  . . . . . . . . . . . . . .. . . . . :

FILE       QRPGLESRC                

     Library . . . . . . . . . . . . . . . . .

:            IROBO1                   

Page 13: Basics of AS/400

    Type ofinformation . . . . . . . . . . . . :

TYPE      *MBRLIST                 

    Fileattributes . . . . . . . . . . . . . . :

FILEATR    *ALL                     

   System  . . . . . . . . . . . . .. . . . . :

SYSTEM     *LCL                     

  FileDescription

Header                                                             

   File  . . . . . . . . . . . . . .. . . . . :

FILE       QRPGLESRC                 

    Library. . . . . . . . . . . . . . . . . .

:           IROBO1                   

    Type

offile  . . . . . . . . . . . . . . .:            Physical                 

    Filetype . . . . . . . . . . . . . . . . . :

FILETYPE   *SRC                     

   Auxiliary storage pool

ID . . . . . . . . . :            00001                    

  MemberList                                                                      

   

                               SourceCreation    Last

Change                  Deleted

  Member           Size        Type Date       Date     Time     Records    Recor

ds

  ACCOUNT                8192PF     10/19/12 10/19/12

19:15:50          8          0

    Text:  ACCOUNT

RELATEDINFORMATION                                                

  PRINT1                16384PRTF   10/19/12 10/19/12

19:17:53         66          0

    Text:  PRINTER DDS

RLUGENERATED                                                  

  PRINT1PGM              8192RPGLE  10/19/12 10/19/12

19:15:50         15          0 

    Text:  rpgle program

forprint1                                                   

   Totalnumber of

members  . . . . . . . . .:                 3                      

   Totalnumber of members not

available  . .:                 0                      

   Totalrecords  . . . . . . . . . . . . . .

:                89                      

   Totaldeleted

records  . . . . . . . . . .:                 0                      

   Total ofmember

sizes  . . . . . . . . . . :             32768                   

Page 14: Basics of AS/400

 Physical file         It is a file which. Contains the data in predefined structured format.

         It’s type PF. By using CRTPF command to create PF.

         Maximum number of fields included in a PF is 8000.

         Maximum no of key fields included is 120.

         The structure of the PF is given below:

PHYSICAL FILE INTERNAL STRUCTURE

TYPE SPECIFIC ATTRIBUTE: Specific to its type

TYPE INDEPENDENT ATTRIBUTE: Creation date, author, size, expiration detail

KEYED ACCESS PATH: An area within a physical file obj where key field data is stored in the order along

with their RRN

 

 

 Levels of entries in physical fileColumns . . .

:    1  71           Browse                         AMINEM/DDSSRCSEU==>                                                                  A

CCOUNTFMT PF .....A..........T.Name++++++RLen++TDpB......Functions+++++++++++++

+++++*************** Beginning of data *****************************

 0001.00     A                            UNIQUE         >>>>> FILE LEVEL0002.00      A          R ACCOUNT                       >>>>> RECORD

FORMAT LEVEL0003.00      A            ACLEVELID      2P 00004.00      A            ACORGCOD       3P 0           >>>>> FIELD LEVEL0005.00      A            ACCOUNTNUM    12P 0

TYPE SPECIFIC ATTRITIBUTE

TYPE INDEPENDENT ATTRIBUTE

RECORD FORMAT

KEYED ACCESS PATH

RECORDS

Page 15: Basics of AS/400

0006.00      A            ACCURRENCY     3A0007.00      A            ACNAME        20A0009.00      A          K ACLEVELID0010.00      A          K ACORGCOD                      >>>>> KEYFIELD

LEVEL0011.00      A          K ACCOUNTNUM0012.00      A          K ACCURRENCY****************** End of data ********************************

 

 

       I.            File level entries (optional): File level entries give the system information of the

entire file. UNIQUE, LIFO, FIFO, FCFO, REF are the keywords used at file level.        

UNIQUE: A record cannot be entered or copied into a file if its key value is same as the key value 

of a record already existing in the file.

FIFO: The duplicate key records will retrieved in first in first out order.

LIFO: The duplicate key records will retrieved in last in first out order.

FCFO: The duplicate key records will retrieved in first changed first out order.

REF: This   keyword   is  used   to   specify   the  name of   the  file   from which   the fields  are   taking 

definition.      

 

    II.            Record format level entries: For a PF the record format name is specified along

with an optional text description. The record level entries can be FORMAT, TEXT.

FORMAT:

This record-level  keyword specifies that the record format being define is to share the field specifications  of  a  previously  defined  record   format.  The  name of   the   record   format  being defined must be the name of the previously defined record format.

             The format of this keyword is:

  FORMAT (LIB-NAME / FILE-NAME)

 TEXT:

 This record level keyword is used to supply a text description of the record format and it is used 

for    documentation purposes only.

 The format of this keyword is:

Page 16: Basics of AS/400

 TEXT (‘description’)

 

   III.            Field level entries: The field names and field lengths are specified along with and

optional text description for each field. (ALIAS, ALWNULL, CCSID, CHECK,

CHKMSGID, CMP, COLHDG, COMP, DATFMT, DATSEP, DFT, EDTCDE, EDTWRD,

REFFLD, REFSHIFT, TEXT, TIMEFMT, TIMESEP, VALUES, VARLEN)

 

  IV.            Key field level entries: The field names used as key fields are specified. (DESCEND,

SIGNED, ABSVAL, UNSIGNED, ZONE, NOALTSEQ, DIGIT)

 

 

  File level keywords FIFO, LIFO, FCFO

FIFO: The duplicate key records will retrieved in first in first out order.           

LIFO: The duplicate key records will retrieved in last in first out order.            

FCFO: The duplicate key records will retrieved in first changed first out order.

  When the FIFO, FCFO, or LIFO keyword is not specified, no guaranteed order is   specified for 

retrieving records with duplicate keys.

  No specific order for duplicate key fields allows more access path sharing, which can improve 

performance.

 Arranging duplicate keys:

  If you do not specify the Unique (UNIQUE) keyword in data description specifications (DDS),

you can specify how the system stores records with duplicate key values.

  You specify that records with duplicate key values are stored in the access path in one of the

following ways:

Last-in-first-out (LIFO): When the LIFO keyword is specified, records with duplicate key

values are retrieved in LIFO order by the physical sequence of the records. Here is an example of

DDS using the LIFO keyword.

Page 17: Basics of AS/400

      A                                    LIFO      A          R REC2      A            .      A            .      A            .      A          K EMPNO

 

Assume that a physical file has the FIFO keyword specified (records with duplicate keys are in

FIFO order), and that the following table shows the order in which records were added to the

file.

Order in which records were added to file

          Key value

1 A

2 B

3 C

4 C

5 D

The sequence of the access path is FIFO, with ascending key values.

Records 3 and 4, which have duplicate key values, are in FIFO order. That is, because record 3

was added to the file before record 4, it is read before record 4.

Page 18: Basics of AS/400

                                                                    This would become apparent if the records were read

in descending order. This can be done by creating a logical file based on this physical file, with

the DESCEND keyword specified in the logical file.

The sequence of the access path is FIFO, with descending key values.

Record number   Key value access order

5 D

3 C

4 C

2 B

1 A

If the key value of physical record 1 is changed to C, the sequence of the access path for the

physical file is FIFO, with ascending key values.

Record number    Key value access order

2 B

1 C

3 C

4 C

5 D

Finally, changing to descending order, the new sequence of the access path for the logical file is

FIFO, with descending key values.

Record number     Key value access order

5 D

1 C

Page 19: Basics of AS/400

Record number     Key value access order

3 C

4 C

2 B

After the change, record 1 does not appear after record 4, even though the contents of the key

field were updated after record 4 was added.

The FCFO order of records with duplicate key values is determined by the sequence of updates

made to the contents of the key fields. In the preceding example, after record 1 is changed such

that the key value is C, the sequence of the access path is FCFO, with ascending key values only.

  Record number    Key value access order

2 B

3 C

4 C

1 C

5 D

 

 File level keywords REFUSE OF REFERENCE                                                  

 

Columns . . .

:    1  71           Browse                        AMINEM/DDSSRC

SEU==>                                                                   

REFER

FMT PF .....A..........T.Name++++++RLen++TDpB......Functions+++++++++++++

+++++

Page 20: Basics of AS/400

       *************** Beginning of data

*************************************

0002.00      A          R REF

0003.00      A            RAC1           2P 0       COLHDG('LEVEL ID')

0004.00      A            RAC2           3P 0       COLHDG('ORG CODE')

0005.00      A            RAC3          12P 0       COLHDG('ACCOUNT NUM')

0006.00      A            RAC4           3A         COLHDG('ACCOUNT

CURRENCY')

0007.00      A            RPOSTCODE      2P 0       COLHDG('POST CODE')

0008.00      A            RCOUNTRY       3P 0       COLHDG('COUNTRY

CODE')

0009.00      A            RNAME         20A         COLHDG('NAME')

0010.00      A            RDATE          3P 0       COLHDG('DATE')

          ****************** End of data

****************************************

 

                                                               

 

Now we can refer the file ‘REFER’ to take the field definition in the new file.

 

 

Columns . . . :    1  71           Browse                        AMINEM/DDSSRC 

SEU==>                                                                  USEREF 

FMT PF .....A..........T.Name++++++RLen++TDpB......Functions+++++++++++++++++

+        

*************** Beginning of data *************************************

0002.00      A                                      REF(REFER)                 

Page 21: Basics of AS/400

0003.00      A          R USEREF                                               

0004.00      A            ACCLVL    R               REFFLD(RAC1 REFER) >>>>>>  field

name and

0005.00                                             ALIAS(ACC_LVL_ID)     referred

file name

0007.00      A            ACCORG    R               REFFLD(RAC2 REFER)            

0008.00                                             ALIAS(ACC_ORG_CODE)        

0009.00      A            ACCNUM    R               REFFLD(RAC3 REFER)         

0010.00                                             ALIAS(ACC_NUM)             

0011.00      A            ACCCUR    R               REFFLD(RAC4 REFER)         

0012.00                                             ALIAS(ACC_CUR)             

0013.00      A            ACCNAME   R               REFFLD(RNAME REFER)        

0014.00                                             ALIAS(ACC_NAME)            

 

  ****************** End of data ****************************************

 

                                                                            

Both(COLHDG & ALIAS) are used to identify fields. COLHDG &  ALIAS is the Description of fields. The 

difference is that in ALIAS we can access data based on that ALIAS name, while COLHDG is not allowed. 

Suppose in PF field name as DES78, give ALIAS as Description78, then user can access data from using 

Description78.

 

   Related Command 

  Create Physical File (CRTPF) 

CRTPF FILE(AMITNEM/OBJ) SRCFILE(AMINEM/QDDSSRC) SRCMBR(OBJ_SRC)

Page 22: Basics of AS/400

 

  The above command is similar to taking option-14 against the source member in member PDM(WRKMBRPDM).

 

  If there is any data in the physical file and you are using CRTPF/option-14, then all the data in the physical file will be lost.

 

  Change Physical File (CHGPF) 

CHGPF FILE(AMITNEM/OBJ) SRCFILE(AMINEM/QDDSSRC) SRCMBR(OBJ_SRC) 

 

  If you don’t want to lose the data, but you want to compile the source member, then you can achieve this by CHGPF command. 

  We generally use CHGPF to change the attribute which are highlighted below. 

                          Change Physical File

(CHGPF)                         

                                                                          

     

 Type choices, press

Enter.                                                    

                                                                          

     

 Physical

file  . . . . . . . . .                 Name                         

   Library  . . . . . . . . . . .     *LIBL       Name, *LIBL,

*CURLIB         

 System . . . . . . . . . . . . .   *LCL          *LCL, *RMT,

*FILETYPE        

 Source file  . . . . . . . . . .   *NONE         Name,

*NONE                  

Page 23: Basics of AS/400

   Library  . . . . . . . . . . .                 Name, *LIBL,

*CURLIB         

 Expiration date for member . . .   *SAME         Date, *SAME,

*NONE           

 Maximum members  . . . . . . . .   *SAME         Number, *SAME,

*NOMAX        

 Access path size . . . . . . . .   *SAME         *SAME, *MAX4GB,

*MAX1TB      

 Access path maintenance  . . . .   *SAME         *SAME, *IMMED, *REBLD,

*DLY  

 Access path recovery . . . . . .   *SAME         *SAME, *NO, *AFTIPL,

*IPL    

 Force keyed access path  . . . .   *SAME         *SAME, *NO,

*YES             

 Member

size:                                                                  

   Initial number of records  . .   *SAME         1-2147483646, *NOMAX,

*SAME  

   Increment number of records  .   *SAME         0-32767,

*SAME               

   Maximum increments . . . . . .   *SAME         0-32767,

*SAME               

 

 Maximum file wait time . . . . .   30            Number, *SAME, *IMMED,

*CLS  

 Maximum record wait time . . . .   60            Number, *SAME, *IMMED,

*NOMAX

 Share open data path . . . . . .   *SAME         *SAME, *NO,

*YES             

 Max % deleted records allowed  .   *NONE         1-100, *NONE,

*SAME          

Page 24: Basics of AS/400

 Reuse deleted records  . . . . .   *YES          *SAME, *YES,

*NO             

 Sort sequence  . . . . . . . . .   *HEX          Name, *SAME, *SRC,

*JOB...   

                                                                          

     

                                                                         

Bottom

 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this

display   

 F24=More

keys                                                                 

 

 

Can LEVEL CHECK ERROR occur if we do CHGPF? It depends on the value that we have set for LVLCHK (Record format level check) attribute.

If its value is *YES then the record format level identifier is checked when the file is opened and if it  doesn’t match it throws the error.

If its value is *NO, then the record format level identifier is not checked, hence no error.

  CHGPFM  

                     Change Physical File Member (CHGPFM)                     

                                                                          

     

 Type choices, press

Enter.                                                    

                                                                          

     

Page 25: Basics of AS/400

 Physical file  . . . . . . . . . >

MASTER        Name                         

   Library  . . . . . . . . . . . >   AMINEM      Name, *LIBL,

*CURLIB         

 Member . . . . . . . . . . . . . > *FIRST        Name,

*FIRST                 

 Source type  . . . . . . . . . .   *NONE         Name, *SAME,

*NONE           

 Expiration date for member . . .   *NONE         Date, *SAME,

*NONE           

 Share open data path . . . . . .   *NO           *SAME, *YES,

*NO             

 Text 'description' . . . . . . .   'ACCOUNT RELATED

INFORMATION               

       '                                                                  

      

                                                                          

     

 

                                                                         

Bottom

 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this

display   

 F24=More

keys                                                                 

    Display file description(DSPFD)

  It is used to display the details about the file.

 

  Display file field description(DSPFFD)  It is used for listing details about individual fields.

Page 26: Basics of AS/400

 Reorganize physical file member(RGZPFM)  We generally use RGZPFM to reuse the deleted records of a file for future insert operation.

The data in a file in inserted sequentially. If we delete some in between records, then

those freed spaces won’t be used for inserting new record. Like this, the toll of space

accumulated by deleted records goes on and we cannot use them until and unless we run

RGZPFM command to reorganize the space.

  Once we delete the records the relative record number of the records gets changed due to

reorganization of file.

  Suppose a file is used in most of the programs based on its key value. If we want to change

the access path of this file from sequential to keyed or from one key value to another key

value, then we can go for RGZPFM.

 

Example:

Below records are according to arrival sequence.

ACCOUNT        ORG   ACC           CCY  PARTY         000001 190   A00000000001  CCY  P00000000001  000002 191   A00000000002  EUR  P00000000002  000003 192   A00000000003  USD  P00000000003  000004 192   A00000000004  TRY  P00000000004  000005 190   A00000000005  INR  P00000000005  000006 190   A00000000006  TRY  P00000000006  000007 192   A00000000007  INR  P00000000007  000008 191   A00000000008  GBP  P00000000002  000009 191   A00000000009  USD  P00000000001  000010 195   A00000000010  EUR  P00000000003  000011 193   A00000000011  TRY  P00000000005  000012 192   A00000000012  EUR  P00000000002  000013 190   A00000000013  EUR  P00000000009  000014 191   P00000000014  USD  P00000000004  000015 192   A00000000015  INR  P00000000010  000016 192   A00000000016  GBP  P00000000011  000017 192   A00000000017  AZK  P00000000017  000018 191   A00000000018  EUR  P00000000014  000019 190   P00000000019  EUR  P00000000015   

Now we want to arrange the records according to the key value(ORG/ACC/CCY) of file

ACCOUNT. For this we set the KEYFILE = *FILE.

If we want to arrange the records based on some other key value then we can give the logical file

name containing that key value. 

                     Reorganize Physical File Mbr (RGZPFM)                                                                  Type choices, press Enter.                                                                                                  Data base file . . . . . . . . . FILE         > ACCOUNT       

Page 27: Basics of AS/400

  Library  . . . . . . . . . . .              >   QGPL        Member . . . . . . . . . . . . . MBR          > ACCOUNT       Key file:                        KEYFILE                        Logical file . . . . . . . . .              > *FILE  >>>>>>>>>>>           Library  . . . . . . . . . .                                Member . . . . . . . . . . . .                              Rebuild access paths . . . . . . RBDACCPTH      *YES           Allow cancel . . . . . . . . . . ALWCANCEL    > *NO                                                                                                    Additional Parameters                                                                             Source update options  . . . . . SRCOPT         *SAME         

                                                                                                                            

After reorganizing, the records in ACCOUNT get arranged as per the key value of ACCOUNT.        ORG   ACC           CCY  PARTY      000001 190   A00000000001  CCY  P00000000001000002 190   A00000000005  INR  P00000000005000003 190   A00000000006  TRY  P00000000006000004 190   A00000000013  EUR  P00000000009000005 190   P00000000019  EUR  P00000000015000006 191   A00000000002  EUR  P00000000002000007 191   A00000000008  GBP  P00000000002000008 191   A00000000009  USD  P00000000001000009 191   A00000000018  EUR  P00000000014000010 191   P00000000014  USD  P00000000004000011 192   A00000000003  USD  P00000000003000012 192   A00000000004  TRY  P00000000004000013 192   A00000000007  INR  P00000000007000014 192   A00000000012  EUR  P00000000002000015 192   A00000000015  INR  P00000000010000016 192   A00000000016  GBP  P00000000011000017 192   A00000000017  AZK  P00000000017000018 193   A00000000011  TRY  P00000000005000019 195   A00000000010  EUR  P00000000003