510 pts.
 Same files in different AS/400 RPG library
I would like to declare same files which are in two libraries in my RPG III. one file in in read only mode and another in update mode.

Software/Hardware used:
AS400
ASKED: January 6, 2011  4:04 AM
UPDATED: January 6, 2011  10:33 PM

Answer Wiki:
The two files need to have two different names in the F specs of your program. Then you can do a OVRDBF before the call to the program. You can also specify the library of the 2nd file within your RPG program.
Last Wiki Answer Submitted:  January 6, 2011  2:42 pm  by  CharlieBrowne   33,730 pts.
All Answer Wiki Contributors:  CharlieBrowne   33,730 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Here’s some code that declares file QCUSTCDT from library QIWS as well as file QCUSTCDT from a library named in a variable:

     FQCUSTCDT1 if   e             disk    extfile( 'QIWS/QCUSTCDT' )

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

     D CUSTCDT2        s             21
     D CDMBR           c                   'MYMBR'

                         CUSTCDT2  = %trimr( PgmLib ) + '/'
                                   + 'QCUSTCDT' ;

There are more options there than you need. The two F-specs use slightly different techniques. Use only pieces that you really need.

The requirement is that the compiler needs file descriptions named “QCUSTCDT1″ and “QCUSTCDT2″ at compile-time because those are the F-spec names. You can either create duplicate file descriptions in a library in your library list when you compile or execute OVRDBF before the compile command executes. There is no need to run OVRDBF when the program runs if you do it this way.

When you duplicate a file description for this, you don’t need the data. Nor do you even need any members. The file description objects are small enough not to make any real difference to your system. If necessary, they can be deleted after the compile finishes; but I prefer keeping them in a development library for later reference.

Tom

 110,135 pts.