File open RPG

5 pts.
Tags:
AS/400
RPG
Is there a way in an rpg program to open a file using a character field for the filename? for example: if my file name is TESTFILE I can use the line: (in rpg free)   OPEN TESTFILE; but is there a way to have character field in place of the filename:   D filename           S             10 /free     filename = 'TESTFILE';     open filename;   

Software/Hardware used:
v5r3

Answer Wiki

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

Your F spec would need two keywords

F filename E DISK USROPN EXTFILE(myfile)

D myfile S 10
/free
myfile = ‘TESTFILE’;
open filename;

When you compile the program either
1. a file by the name of FileName should exist in your library list with the correct structure for your program to map the field from

or
2. do an OvrDbf Filename Testfile shave(*yes) to point the use of filename to an existing example of the file structure,
then compile,
then dltovr filename

Phil

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