+ Reply to Thread
Results 1 to 10 of 10

Thread: OPNQRY ?

  1. #1
    Guest.Visitor Guest

    Default OPNQRY ?

    Can you use a SETLL AND a READE on a file that is being queried in a CLLE program and being used as a fully procedural file in a RPGILE program? It seems to run fine, but my program is not finding any records (MY SETLL INDICATOR IS OFF). The program is not processing any records in the file. I have done this successfully in the past with a Input Primary file. Thank you. Kirk

  2. #2
    Guest.Visitor Guest

    Default OPNQRY ?

    SETLL wil NOT set the file pointer on a file opened with the OPNQRYF command, (at least that's my experience), you can still set the file pointer by executing the POSDBF command inside your program. For ex: POSDBF OPNID(file_name) POSITION(*START) HTH

  3. #3
    Guest.Visitor Guest

    Default OPNQRY ?

    Hi Kirk, Let me try if I can be of any help to you. You can do READE,SETLL or whatever on a file that is being queried in a CL program. It is not a problem at all!!! You need to check with your SETLL and READE statements again. You said SETLL is find and is keeping the indicator off. But it is not reading any record?? What about the factor1 entry for READE? Is it okay? If the situation is like we want to trap some records bearing exactly the same key value then we tend to give the key value for both SETLL and READE. Not giving key value for READE is optional though. However,we set the pointer using SETLL and do not happen to find the very first record on reade operation with key value then it won't get us anything. If the problem is beyond the scope of this explanation, please write a line or two, we can discuss activation groups which is a whole new concept for ILE environment and have some affect on file operations. Thank you, Anil

  4. #4
    Guest.Visitor Guest

    Default OPNQRY ?

    I think you would be better off creating a Logical view of the file, incorporating any selection criteria and the key order that you want.

  5. #5
    Guest.Visitor Guest

    Default OPNQRY ?

    I agree with Alan! You can not use SETLL to set initial file poniter with OPNQRY file.I had the same problem and I could not resolve the issue but then I used POSDBF to read the file from begining and checked the specific value which was time consuming.

  6. #6
    Guest.Visitor Guest

    Default OPNQRY ?

    I believe you will find that you are able to use SETLL on a file processed by OPNQRYF, if the file is defined as a keyed file in the "F" specs, and *FILE is specified for the indexed fields within the OPNQRYF statement. Dave

  7. #7
    Guest.Visitor Guest

    Default OPNQRY ?

    I didn't know that; what if you want key fields different from *file?

  8. #8
    Guest.Visitor Guest

    Default OPNQRY ?

    Wellllll, If you specify a keyed file in your program, the program is going to automagically impose the normal key of the file. When the program is compiled, it will not know if you are going to use OPNQRYF or not! If you OVRDBF with a shared open, and use OPNQRYF with a key other than *FILE, it's a safe bet that the program will ignore the previous OPNQRYF open. An error message may also result. If you do not specify use of a key in your HLL program, then the sequencing of OPNQRYF will be in effect, however, you can not use SETLL with a key, but without a keyed open. In other words, specifying a keyed file in an HLL program means the normal key of the file must be used, and not some other key. What you can do, is use OPNQRYF over a logical file, that contains the key you want to use. You must still use *FILE in the OPNQRYF command. This gets even crazier when using mapped fields, format files, and GROUP statements. Dave

  9. #9
    Guest.Visitor Guest

    Default OPNQRY ?

    Try opening the file with KEYFLD(*FILE) and SEQONLY(*NO). The default of the SEQONLY parameter is normally *YES which means that you can only read the file opened by OPNQRYF sequentially. SEQONLY(*NO) allows you to access the file dynamically, SETLL CHAIN etc... However you will have to use KEYFLD(*FILE) in order to be able to define the keys in the RPG Program.

  10. #10
    Guest.Visitor Guest

    Default OPNQRY ?

    What I have done to use an open query file with different keys is the following: Create an alpha field in the open query file that is as long as the longest key that could be used. If multiple fields will be used for a single key than add up all the lengths and include that in your total field length for that one alpha key field. Then in the CL program have logic that decides what key is going to be used in the RPG program. Then map that key field, or fields, into that one alpha field. Then in the RPG program you have logic that tells what key is in use. After you know what field(s) make up the key you can set up the alpha key field in the RPG program, may have to concatanate some fields together, and SETLL or CHAIN. Works great. By the way, you need to tell the RPG program that the query file is keyed.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts