185 pts.
CL Commands
Override with Database File
Sir, Im less aware abt OVRDBF concept plz tell me When it is used?, If we Override one file then it is allowed in other program? When it is allowed when not allowed? Like that  , Explain me with Example ....   Thankyou in advance

Answer Wiki

Thanks. We'll let you know when a new response is added.

An OVRDBF used in one job does not have any effect on other jobs.

A simple example would be if you have an RPG program that uses FILEA.

Here is a CL to use FILEB instead.


In this case he DLTOVR is not ready needy since the job will end, but it is a good practice to get into.


Database files on AS/400s are compiled objects that expose specific methods and have specific attributes. A program that is compiled over a database file can only process that particular file.

Compiled database file object objects have “signatures” called ‘record format identifiers’. The format ID becomes embedded in the compiled program at compile time. When the program runs and opens a file, the system compares the embedded format ID to the format ID of the file that gets requested. If the IDs match, all is well. Otherwise DB2 signals a “level check” error.

Because the format ID is what gets checked, the question is whether or not two (or more) separate database files can have matching format IDs. If they do, then OVRDBF (Override with Data Base File) can be used to redirect to them at run-time.

In general, you compile a program that references a file at compile-time. You issue OVRDBF to reference a different file with the same format ID at run-time.

One common reason to do this is to process a file that doesn’t exist until you are going to run the program. And one common reason is that you will create the file by running a command that will create the file as an “outfile”, and then run the program to process the file that you just created.

An example of a command that will create an outfile is DSPOBJD. If you run the command like this:<pre>
…it will create a file named MYPGMS in library QTEMP. But how do you know how to compile a program that will process that file?

The help-text for the OUTFILE() parameter tells you that the command will create a file in the format that is defined by an IBM-supplied file named QADSPOBJ. You should be able to find that file in library QSYS.

You can compile your program by referencing the QADSPOBJ file. After you run the DSPOBJD command, you can issue this command:<pre>
Then you can call your program, and your program will read the MYPGMS file in QTEMP instead of QADSPOBJ. The system guarantees that MYPGMS will have the same format ID as QADSPOBJ.

Many commands create outfiles. The help-text on those commands tells you the file names that you should compile over. Use OVRDBF to override to the name that you actually process.

At other times, you might use CRTDUPOBJ to duplicate a file and give the duplicate a different name. OVRDBF lets you write a program that is designed to process the original file but that actually processes a copy of the data in the duplicate file.


Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: