How can I open file from another library in RPG program

Tags:
RPG
RPG Programs
Hi, my requirement is how can I open a file from another library in RPG program … noted that I have tried to use keyword : EXTFILE(LIBRARY _Nam / FILE_Nam) but it doesn’t work. Please advise. Thanks! Tarek yaseen

Software/Hardware used:
software

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: 16  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
    EXTFILE(LIBRARY _Nam / FILE_Nam) but it doesn’t work . Doesn't work ... works for me.  Please explain how you know that it doesn't work. 
    49,550 pointsBadges:
    report
  • TomLiotta
    Yes, it does work. You can't tell us what you tried. You have to show us. Also, saying that it "doesn't work" isn't enough. You have to tell us what happened. Was there an error message? If so, which one? If not, did it open the wrong file? -- Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    EXTFILE(LIBRARY_Nam/FILE_Nam)1.  If these are variables you should designate the file USROPN2.  It should probably be 1 21 char variable that gets populated with the actual values and the /.3.  Open the file after the variable is populated. 
    49,550 pointsBadges:
    report
  • philpl1jb
    sorry a type USROPN !
    49,550 pointsBadges:
    report
  • philpl1jb
    and all caps.
    49,550 pointsBadges:
    report
  • Senior1systemanalyst
    Normal 0 false false false EN-US X-NONE AR-SA MicrosoftInternetExplorer4 Dear all - Many thanks for your response You all right I’m sorry for missing details ….. But unfortunately   I’m currently out of office I will provide you with the message appeared when I tried to use this command. Regards, /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}
    260 pointsBadges:
    report
  • philpl1jb
    We'll need more - F specs, D specs, C specs that relate to this issue.
    49,550 pointsBadges:
    report
  • ToddN2000
    Another option is to do an OVRDBF in the RPG using the QCMDEXEC command. Are you locked into doing this a specific way ?
    8,335 pointsBadges:
    report
  • ToddN2000
    Forgot to add you would still need to make the file user controlled and then do the file override to the other library , open file and close file commands manually.
    8,335 pointsBadges:
    report
  • hellofriends
    try this below mentioned way... it definitely works.
    FFile  I F   E      K    Disk EXTFILE(@Lib)
    D@Lib1      S        30A  
    C*
    C                 Eval   @Lib = 'Library1/FIle name'
    35 pointsBadges:
    report
  • philpl1jb
    hellofriends That's very nice but your code requires USROPN on the F spec and Open File1 in the C-spec.  Files that aren't USROPN are opened by the cycle ... before any C spec's are run and while it's open it isn't going to "re-target".  
    49,550 pointsBadges:
    report
  • TomLiotta
    Note that USROPN should only be required if the value of EXTFILE() is variable. If it's constant, it can have the appropriate value at the time files are opened by the Cycle. -- Toml
    125,585 pointsBadges:
    report
  • Senior1systemanalyst
    Gents The message appeared was: ‘A right parenthesis is expected but is not found’  when I used keyword  EXTFIL(Library_Name/FILE_Nam) However, the below commands used and it works fine. FCUSTMAST  IF   E           K DISK    EXTFILE (myFile)  D myFile          S             21A   Inz(‘KINPLIV/CUSTMAST’) Many thanks… for your attention Tarek
    260 pointsBadges:
    report
  • Senior1systemanalyst
    Normal 0 false false false EN-US X-NONE AR-SA MicrosoftInternetExplorer4 Correction: EXTFILE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}
    260 pointsBadges:
    report
  • TomLiotta
    The message appeared was: ‘A right parenthesis is expected but is not found’...   Message text is often less helpful than the message identifier. Different messages can have the same text.   when I used keyword  EXTFIL(Library_Name/FILE_Nam)...   In this case, the message text is helpful. You didn't show enough for us to see what Library_Name and FILE_Nam are, but now the text helps.   You can't use two variables for library and file. You can only use a single variable to hold the entire name. When the compiler found the variable Library_Name, the next thing it expected to find was a right-parenthesis. Instead it found a slash character, "/". The compiler didn't know what to do with the slash, so it told you what it expected to find that was missing.   Tom
    125,585 pointsBadges:
    report
  • Senior1systemanalyst
    thanks Tom for clarifications.Tarek
    260 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