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)’);
// open the file.
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.