ovrdbf in rpg

10 pts.
Tags:
DDS
OVRDBF
RPG
hi guys.. i am getting a file name as a variable from CL program. based on some condition i want to write in differnt members of the file.since the file name is stored in a variable i cant able to declare it in f spec. so i created a duplicate object for that file and i declare it in f spec. Now i want to override that file to the filename stored in the variable and to different members... any clues Guys... If possible provide some examples it ll be useful. since the filename is stored in a variable i dont know how to override.

Software/Hardware used:
as400-RPG
ASKED: November 29, 2009  6:04 AM
UPDATED: November 30, 2009  8:16 PM

Answer Wiki

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

Use the USROPN keyword in the F spec for the file.
Then just prior to doing an OPEN in the calc spec, call QCMDEXEC to do an OVRDBF to the file and/or member you want to use.
*
Here is an example:
// override to new member.
cmdString =’OVRDBF FILE(ADDLNAMMBR) TOFILE(‘ + %trim(&fileName)’);

callp cmd(cmdString:300);

// open the file.
open ADDLNAMMBR;

==========================================================

It depends on what version/release you’re running and whether you’re programming in ILE RPG or RPG/400.

Recent ILE RPG allows you to use variables for both file name and member name. The file will be a USROPN file. Assign values to the variables and open the file. Here’s some code using a variable for a fully-qualified file name and a constant for member name:<pre>
FQCUSTCDT1 if e disk extfile( ‘QIWS/QCUSTCDT’ )

FQCUSTCDT2 if e disk usropn
f extfile( CUSTCDT2 )
f extmbr( CDMBR )
f format( CUSREC : CUSREC2 )
f prefix( QC : 2 )

D CUSTCDT2 s 21
D CDMBR c ‘MYMBR’

CUSTCDT2 = %trimr( PgmLib ) + ‘/’
+ ‘QCUSTCDT’ ;</pre>Note that when compiled, the compiler needs to find file descriptions for both “QCUSTCDT1″ and “QCUSTCDT2″. Those can simply be temporary file objects that are deleted once the compile is finished.

There are no overrides for this kind of coding. The RPG does it all. RPG/400 does not allow this technique, so it still requires OVRDBF.

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