AS400 OPNQRY FILE

1215 pts.
Tags:
OPNQRY
OPNQRYF
RPGLE Program
I want to use one non keyed Physical file as keyed file in RPGLE Program. I want to achieve this OPNQRYF Command. Is it possible? If 'Yes', How to compile the RPGLE Program? Eg: File1 - Non Keyed File Program1 I want to use FFILE1IF E K DISK How do i achieve this?

Answer Wiki

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

Instead of OPNQRYF, today we see a lot more use of embedded SQL.

To compile the program, create a CL similar to the run time CL with
1. OVRDBF
2. OPNQRYF
3. CRT … calls to create your rpg program
4. CLOF
5. DLTOVR

Run this CL to create the program
You will want to save this CL for future compiles.

Discuss This Question: 11  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
  • rajeshece
    Hi, Still i am getting the error message RNF7081 - The File operation is not valid; there are no common key fields. The specification is ignored.
    1,215 pointsBadges:
    report
  • philpl1jb
    http://www.mcpressonline.com/tips-techniques/database/techtalk-opnqryf-mapfldand-keyfld.html http://itknowledgeexchange.techtarget.com/itanswers/opnqryf-7/ Show us the cl & RPG F spec and Chain or Setll Phil
    49,950 pointsBadges:
    report
  • TomLiotta
    Note that Phil is discussing the CL that is necessary to create your program. In order to compile, the compiler needs to find a matching file. You do that by wrapping your CRTxxx command in CL that runs OPNQRYF in the same job as the CRTxxx command runs in. When that job finishes, the OPNQRYF goes away and the program has been created. If it's not working for you, Phil wants to see the CL that attempted to create the program as well as the F-spec that references the OPNQRYF. The two -- the OPNQRYF and the compile -- must run together and must match. (There is an alternative method, but the OPNQRYF must match the F-spec either way.) Tom
    125,585 pointsBadges:
    report
  • VGP
    Tom and Phillip, I starting having an issue with a RPG program after it was recompiled due to a different file change 2 weeks ago. I was searching for something like my issue and found this that sounds like it may be what is happening to me. The program was working fine until the recompile. Since that recompile the OPNQRYF is no longer working. The physical file is keyed by shipto and the opnqryf command says to use billto. The RPG that is called is using the arcust in shipto order. Below is a snippet of the CL. OVRDBF FILE(ARCUST) TOFILE(&CSLIB/ARCUST) SHARE(*YES) OPNQRYF FILE((ARCUST)) OPTION(*ALL) + KEYFLD(BILLTO) CALL PGM(ARR0402) PARM(&AGCY &AGNAME &EDATE + &DETAIL &BTTOT &DAYS1 &DAYS2 &DAYS3 + &DAYS4 &DAYS5 &BSUM &ARDAYS) Am I understanding it correctly that the ARR0402 program has to be recompiled over an ARCUST file that is in billto order for this to work now? Was this something that changed in OS 6.1? The last time the program was changed was in 2000 and recompiled in 2007 on iSeries OS 5.3.
    300 pointsBadges:
    report
  • philpl1jb
    Hi VGP No, if the two fields have the same structure, you should be able to compile with one field as the key and use this method to substitute another. If we saw the F spec it might give us an idea. Are you using READ commands in RPG(LE??) Other overrides in the job or Activation Group for the same file will keep this from working. Phil
    49,950 pointsBadges:
    report
  • VGP
    Thanks Phillip, yes both billto and shipto are alpha 10. There was a previous ovrdb for calling a different program higher in the CL. I added a dltovr but the same results. The F spec for the arcust file is FARCUST IP E K DISK the program is RPGLE but just compiled with crtbndrpg. It is a very old program so has this file as primary and does reade or chains to other files. This was working correctly until just recompiled. It is weird that this same program is running on a sister company using V5R3 so I am pretty sure it is because it was recompiled on V6R1. I tried to recompile using V5R3 and V5R4 and it still does not work. Thanks, Gail
    300 pointsBadges:
    report
  • philpl1jb
    Oh, I think you need to change the OVRDBF OVRSCOPE to *JOB and of course the DLTOVR commands lvl to *job. Phil
    49,950 pointsBadges:
    report
  • VGP
    Phillip, "I think you need to change the OVRDBF OVRSCOPE to *JOB and of course the DLTOVR commands lvl to *job." I tried that with no change in results. I need to emphasize that our system was on OS 6.1 as of July 23rd. This process was working fine as of 9/14 with the proper sort order. The RPG called in the CL was recompiled 9/18 and on 9/21 the report was no longer in the proper sort order. The CL was not changed or recompiled only the RPG. The ARCUST file was not changed or recompiled either. This is just too weird. I wonder if there is some option in the RPGLE compile that would change the way the OPNQRYF is looked at. I looked but did not see anything. I have searched the IBM site and so far have found nothing there either. thanks for any help. Gail
    300 pointsBadges:
    report
  • philpl1jb
    Gail Please post this as a new thread. I should have said that at the beginning. Then more people will see it and one will surely have the answer. .. I checked out some code .. identical to your CL and RPG and running in 6.1 I would try to simplify the issue. Start with just a cl with a command with the override, opnqryf and the call .. does that work? Phil
    49,950 pointsBadges:
    report
  • TomLiotta
    Please post this as a new thread. That's an excellent suggestion. I saw this by accident today. The original requirement was to compile RPG that used keyed-access over a PF that was not indexed. The ARCUST file has an index and key structure already. The compiler needs to know whatmemory to set up and how to construct the DB access. Since your compile-time and run-time files are both indexed and the keys fit in the same memory, you should be able to redirect from one to the other at run-time.
    FARCUST IP E K DISK 
    That says it's a basic 'I'nput file in 'K'ey order. It's not an 'U'pdate file. But this:
    OPNQRYF FILE((ARCUST)) OPTION(*ALL) +
    KEYFLD(BILLTO)
    implies that updates will be done. Why set up OPTION(*ALL) if only OPTION(*INP) will be used? Regardless. a new question should specifically address your problem Include the CL snippet, the F-spec, the description of the two alternative key fields and a simple overview of the problem. Some might find it useful if you include a link back to this question. I think I can provide an example that will help. Tom
    125,585 pointsBadges:
    report
  • VGP
    here is a link to the new thread created for my question/issue. OPNQRYF and iSeries V6R1 issue http://itknowledgeexchange.techtarget.com/itanswers/opnqryf-and-iseries-v6r1-issue/
    300 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