Using two same files from different libraries in a RPGLE program.

45 pts.
Hi All, Please guide me for the following problem. I got stuck into it. I want to operate same file from two different libraries in a RPGLE program. Remember we are taking the file names at runtime. So we don?t know the structure of files. Like the record format name etc. Again somehow I retrieve the record format name in the CL, but how will I pass it to the RPG program because RENAME keyword in RPGLE does not work with variable name. Could you please tell me that if at runtime you want to handle same file from two different Libraries and don't know its Record Format name then how to handle this?

Answer Wiki

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

Even though more info is needed to guide you, these hints may be of some help to you: 1. Use SQL in your proces. 2. look into the two system files that contains info on files and fields. Run these two Query-commands and you will get a peep into the files: RUNQRY *N QADBXREF and RUNQRY *N QADBIFLD . Both files are accessible by SQL from an RPG-program of type SQLRPGLE. Good luck


QADBXREF and QADBIFLD are physical files in QSYS, maintained for DB2. If at all possible, the files shouldn’t be used directly. The DSPDBR command over them will show all of the various LFs and views that IBM has supplied and those should be used instead, preferably using the views. DB2 itself is always expecting those files to be immediately available for update. Select an appropriate view and let DB2 handle access through the view layer. Improper access to the physical files, or simple bad luck

I’m not sure of any good way to handle the exact question of renaming a record format when the format name isn’t known. I suspect that the most useful method is not to use native I/O. Don’t use access methods that require renaming the format(s).

See the RPG iv with no file definitions… question for suggestions of other methods.


Discuss This Question: 6  Replies

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.
  • Atgidm
    You may also want to look into using the override data base file command - OVRDBF to rename one of your file names or even both of the files if you prefer. Your override will always use the same name so you will list those names in your RPG program.
    0 pointsBadges:
  • Ashnirody
    Copy the files into two files whose record format names are known. This way you do not have to retrieve the format name.
    100 pointsBadges:
  • StanZG
    You can use the rtvobjd to get the library that file is in and based on that know which program to call
    0 pointsBadges:
  • Yorkshireman
    write your program naming the files 'INPUT2' and INPUT2'  and use the field and format renaming, or qualified DS for each set of data.
    specify USROPEN for each

    at run time, call the function from a CLLE which runs an OVERDBF to the required files as INPUT1 or INPUT2. 
    open each file in your program, use it, and close before leaving to enable another pair of files to be used  on another iteration. 

    some looking in the RPGLE manual illustrates some of this

    6,085 pointsBadges:
  • lance2221357
    You can select one LIB create LF  REFACCPTH(PF),
     in RPGLE use  LF, rename record name. another use  PF.
     Two File use EXTNAME(File:*INPUT) QUALIFIED.   
     So File, Record & Field can identify.            
    265 pointsBadges:
  • BibekMajilla

    Please check this below link for more information.
    90 pointsBadges:

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: