OVRDBF help

185 pts.
Tags:
CL Commands
CLLE
Override with Database File
OVRDBF
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

ASKED: September 20, 2010  5:34 AM
UPDATED: September 21, 2010  6:51 AM

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.

PGM
OVRDBF FILEA FILEB
Call RPGPGM
DLTOVR FILEA
ENDPGM

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>
DSPOBJD OBJ( mylib/*ALL )
OBJTYPE( *PGM )
OUTPUT( *OUTFILE )
OUTFILE( QTEMP/MYPGMS )</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>
OVRDBF FILE(QADSPOBJ)
TOFILE(QTEMP/MYPGMS)</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.

Tom

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following