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

45 pts.
Tags:
CLP
IBM DB2
RPGLE
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 <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

Discuss This Question: 3  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.

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
  • 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:
    report
  • 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:
    report
  • 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:
    report

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