OVRDBF and DLTOVR CL commands

OVRDBF and DLTOVR commands in CL.

OVRDBF and DLTOVR commands in CL, Override , OVRDBF , DSPOVR , DLTOVR , SRC, QRPGLESRCas400, ibmi, as400 and sql tricks, as400 tutorial, ibmi tutorial
OVRDBF and DLTOVR commands in CL

Introduction to override commands

We can override either a database file or a DSPF or PRTF file. command used to override display file (DSPF) is OVRDSPF and for printer file (PRTF) its OVRPRTF and that will be covered in a separate article. Here, in this article we will discuss about OVRDBF command to override a database file. override means replace so basically OVRDBF command is used to override i.e. replace the file in the program or override certain parameters of a file that are used by the program or both. This command applies to PF, LF and DDM files.

To override a file named/defined in the program we need to provide that file named in program in FILE parameter and the actual file to be processed in the program in the TOFILE parameter.

To override only certain parameters of the file named/defined in the program we need to pass named file in the program in FILE parameter and *FILE value in TOFILE parameter the use other parameters of the OVRDBF command to override specific paramters of the file.

Some important parameters of the OVRDBF command

  • FILE: specify the file being declared in the program.
  • TOFILE: specify the database file to be used in place of file being overriden i.e. specified in FILE parameter. If the same file is to be processed and only certain parameters to be overriden the specify value as *FILE.
  • MBR: specify the members used within the database file. Possible values are *FIRST, *LAST, *ALL, name of the member. If member name is not specified then first member is used.
  • POSITION: specify the starting position for reading records from the database file. Possible values are *NONE, *START, *END, *RRN(provide relative record number i.e. nth record in file), record specified on key field value (*KEY, *KEYA, *KEYAE, *KEYB, *KEYBE)
  • LVLCHK: specify whether record format level identifier be checked when the file is opened by the program. (*NO/*YES)
  • OVRSCOPE: specify the scope of the override. Possible values are *ACTGRPDFN (The scope of the override is determined by the activation group of the program that calls this command. when default activation group then scope would be call level of calling program otherwise activation group of the calling program), *CALLLVL(The scope of the override is determined by the current call level. All open operations done at higher or same call level than the current call level are affected by this override) , *JOB (The scope of the override is the job in which the override occurs).
  • SHARE: specify whether the open data path (ODP) is shared with other programs in the same routing step. (*NO/*YES)
  • OPNSCOPE: specify the scope of the open operation. Possible values are *ACTGRPDFN(The scope of the open operation is determined by the activation group of the program that called the OVRDBF command processing command. when default activation group then scope would be call level of caller otherwise activation group of the caller), *JOB(The scope of the open operation is the job in which the open operation occurs).
  • Why does override happen in the database?

  • When file is not present in library list.
  • When RPG program refers the file with different name.
  • To process a particular member etc.
  • Examples

    Let's dicsuss some examples to better understand the OVRDBF command.

    Example 1: Overriding a file from another library

    Currently the file is in current library EASYCLASS1 and we want to use file in library EASYCLASS2.

         CLPF1       *FILE     EASYCLASS1  PF          Read PF in CL program 

    Use the OVRDBF command with below parameters to overrride file CLPF1 present in library EASYCLASS2.

                          Override with Data Base File (OVRDBF)                    
                                                                                   
     Type choices, press Enter.                                                    
                                                                                   
     File being overridden  . . . . . FILE           CLPF1                         
     Overriding to data base file . . TOFILE         CLPF1                         
       Library  . . . . . . . . . . .                  EASYCLASS2                  
     Overriding member  . . . . . . . MBR                                          
     Starting position in file:       POSITION                                     
       Retrieve order . . . . . . . .                                              
       *RRN-rcd nbr *KEY-nbr key flds                                              
       *KEY-rec format having key . .                                              
       *KEY-key value . . . . . . . .                                              
    

    Example 2: Overriding an existing member

    OVRDBF   FILE(CLPF1)  MBR(MBR2)

    The above command will override the member MBR2 instead of the first member and therefore MBR2 will get processed in the program instead of first member of file CLPF1.

    Example 3: Overriding a share specification

    OVRDBF   FILE(CLPF1)  SHARE(*YES)

    Any open of this file will use the ODP(open data path) for the file.

    Example 4: Overriding a file

    OVRDBF   FILE(INPUT)  TOFILE(CLPF1)

    The file CLPF1 will be processed instead of file named INPUT.

    How to Delete Overrides?

  • The DLTOVR command removes the one or more file overrides from the file by providing the file name.
  • Parameters of DLTOVR command

  • FILE:Specify the name of the overriden file in the call level whose file overrides are to be deleted. Possible values are *ALL(all the file overrides that exists in the call level is deleted), name of the overriden file in the call level whose override is to be deleted.
  • LVL: specify the call level of the file whose override is to be deleted. Possible values are *ACTGRPDFN (determined by the activation group of the program), *(call level of program), *JOB(OVRSCOPE(*JOB) are deleted).
  • Example 1: Delete Override for one or more file

    DLTOVR FILE(FILE1 FILE2)

    Example 2: Delete Override for all the file

    DLTOVR FILE(*ALL)

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain