RPGLE: How to use klist without compilation error

This is an interview question for Open query but a bit tricky thing also. We are using OVRDBFand OPNQRY to change the key field in LF(TESTLF) FROM A,B,C TO C,B,A,. And going to call RPGLE program, in RPGLE program same LF is declared with C,B,A key list (but according to LF it should be A,B,C). What will happen? I said klist error will occur. To over come this we will use one keyword what is that? I don't have any clue about this. I tried this concept but compilation issue if we use keylist. without keylist (just Use Read opcode) there is no issue the data will be fetched according to C,B,A key list. How to use klist without Compilation Error. I am very eager to know the answer. Please help me with this.

Software/Hardware used:

Answer Wiki

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

We have had occasions where we have needed to do something similar (run-time version of file slightly different in some way). The trick is to have an override at *compile time* so that the compiler can match up your key list with the key fields of the file. Of course this means you either need to have a file object with keys that match the run-time keys & format or you need to build the OPNQRYF just to do the compile.

Discuss This Question: 3  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.
  • Subhendu Sen
    Your query is not cleared here. If you asked for command for creating temporary access path for a file, then you can use OPNQRYF. Please look here for more help: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_61/cl/opnqryf.htm
    142,210 pointsBadges:
  • ToddN2000
    Very strange situation to say the least. Why would you put the wrong key list in a program then have to override it in order to use it? If you want the program to compile with the C,B,A key list you need to do the following. Do an OVRDBF of that file then do an interactive compile (CRTOBJ). This way it will use the definition from the OPNQRY. A batch compile will still use the file definition.
    136,240 pointsBadges:
  • Splat
    Don't use a KLIST.

    Define the file as program described, indexed.

    FQadspdbr  If   f  372    30aiDisk    keyloc(1)                       

    Use either a field or a data structure as the key.

    12,915 pointsBadges:

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.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: