45 pts.
 Using two same files from different libraries in a RPGLE program.
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.

Software/Hardware used:
ASKED: January 3, 2007  4:15 AM
UPDATED: December 28, 2009  6:00 AM

Answer Wiki:
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 <a href="http://itknowledgeexchange.techtarget.com/itanswers/rpg-iv-with-no-file-definitions/">RPG iv with no file definitions...</a> question for suggestions of other methods. Tom
Last Wiki Answer Submitted:  December 28, 2009  6:00 am  by  DanTheDane   2,540 pts.
All Answer Wiki Contributors:  DanTheDane   2,540 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

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 pts.

 

Copy the files into two files whose record format names are known. This way you do not have to retrieve the format name.

 100 pts.

 

You can use the rtvobjd to get the library that file is in and based on that know which program to call

 0 pts.