In RPG program

13030 pts.
Tags:
Application development
AS/400
Backup and Recovery
CLP
RPG
RPGLE
Hi, In RPG program I declared files. One for reading and another for Updating. Both the files are in different Library lists. How do i achieve this? Thanks in Advance Rama krishna

Answer Wiki

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

I am assuming that the 2 files in question have the same filename.

1.In your RPG program you must assign another name to 1 of the 2 database files.

For example, if the name of the files is FILE_A, then rename one of the files to FILE_B. The name you assign SHOULD NOT already exist in the library list that you are using when compiling or executing your RPG program.

Let’s assume that FILE_A is the Update File in LIBRARY_1, FILE_A is the Input File in LIBRARY_2, and your RPG program is being called NEWPGM.

In your F-specs for NEWPGM use FILE_A as the Update File name, and FILE_B as the Input File name. Rename FILE_B’s record format name to FILE_BRCD or to something that CLEARLY distinguishes it from the record format name of the FILE_A update file.

2.Code a CL program to override the two database files before calling your RPG program.

OVRDBF FILE(FILE_A) TOFILE(LIBRARY_1/FILE_A) ..update file
OVRDBF FILE(FILE_B) TOFILE(LIBRARY_2/FILE_A) ..input file
CALL PGM(NEWPGM)
DLTOVR FILE(*ALL)

3. Code a CL program to compile your RPG program

OVRDBF FILE(FILE_A) TOFILE(LIBRARY_1/FILE_A) ..update file
OVRDBF FILE(FILE_B) TOFILE(LIBRARY_2/FILE_A) ..input file
CRTRPGPGM PGM(NEWPGM)
DLTOVR *ALL

Remember to access your database files in your RPG program using the name that you have assigned to that file WITHIN your RPG program. Any access to the Input File should use the FILE_B name or FILE_B record format name.

=====================================================

Both the files are in different Library lists.

The statement doesn’t make sense the way it is written. A “library list” is simply a list of libraries that you create. A file can only be in one library. If you have two files, they can be in the same library or in two different libraries.

If they are in different libraries, you can put both libraries in the same library list. A library list is like a path that the system uses to search for files.

If the two files have the same name, they must be in different libraries.

You can use OVRDBF in an outer CL program (or CL procedure) to direct your RPG program to open the two files under different names. The overrides can be done as noted above.

Or you can code the two files and libraries directly in the RPG program. Review the discussion for ovrdbf in rpg to see an example of coding RPG without needing overrides.

Tom

Discuss This Question:  

 
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

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