Use the filename inside program received as parameter

2505 pts.
Tags:
AS/400
RPG Program
I wanted to write a RPG program which will be called from 3 other CL programs. From 3 CLs this RPG has to use 3 different files in the chain. How can I use the filename inside the chain which is received as parameter? I tried to use FInpFile I F E Disk EXTFILE(pFilename) and populated pFilename with the name received as parameter, but I am getting level40 error on the declaration, it says the file mentioned in the F spec is not an externally described file. I assume because the 'InpFile' is not a file name. How can I use the file name at run time? Waiting for the inputs. Thanks in advance.

Software/Hardware used:
AS400

Answer Wiki

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

Discuss This Question: 8  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
  • philpl1jb
    If the files all have the same record name and structure Your F spec should have a USROPN keyword After you populate pFilename with the name received as parameter Add an OPEN InpFile
    49,550 pointsBadges:
    report
  • TomLiotta
    Also, we need to see how pFilename is defined as well as the (exact) value that is supplied to the program. . Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    BTW, I don't do it, but I expect that USROPN shouldn't be needed if the parm value is passed correctly. -- Tom
    125,585 pointsBadges:
    report
  • RamvishakRamesh
    Files dont have the same record name and structure. In that case, how can I do? pFilename is declared as an alphanumeric field of 10A. (to hold the file name) the value that is passed is the file name of length 10A
    2,505 pointsBadges:
    report
  • TomLiotta
    No, you can't tell us how it's defined. You need to show us how it's defined. And because it's a parm field, we need to see the prototype or the full *ENTRY PLIST because that will be part of the definition. . Also, what do you mean by "Files dont have the same record name and structure"? If the record formats don't match, you will probably need a lot of changes in your program. The only file that the compiler knows the structure of is InpFile (and it has to exist for the compiler to use when it compiles the program). InpFile has to have the same structure as any file named in pFilename. . Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Three files with different record names and structures -- if the program is going to use a few matching fields for some purpose then you might be in dynamic SQL land. -- or you are using 3 f specs for the different files, you may want to use user open and only open the desired file and three chain statements .. perhaps 3 different subroutines or procedures.
    49,550 pointsBadges:
    report
  • philpl1jb
    Or perhaps as an internally defined file .. length of the longest file definition of internal file related to three externally define data structures. .. this is more complex than the three separate f-spec method.
    49,550 pointsBadges:
    report
  • TomLiotta
    ...Especially if they have different records and structures. . Now it's not clear at all what the purpose is. With so little information, it doesn't make sense. . Tom
    125,585 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