Q: I need a little help with Open Query File (OPNQRYF). I have a multiformat logical file built over two physical files-the invoice header and detail files. I want to select certain invoices to print. I am having no problem building the correct string for the QRYSLT parameter. My problem is in using the multiformat logical file. I get record format errors. I want to use this file because it will plug right into the current invoice run program. What do I need in the FILE parameter? What about the FORMAT parameter?
- Eric Hill
A: OPNQRYF will run over a multiformat logical file, but you have to choose one of the formats in the third part of the FILE parameter. One OPNQRYF command won't return records from different formats. These are your options:
1. Run two OPNQRYF commands: one over the header file and one over the detail file. They can reference the physical files or the correct formats of the logical file.
2. Run one OPNQRYF command over the header to select the invoices you want. In your RPG program, read the detail records for each header record with random processing (SETLL, READE). This is assuming that the detail file is keyed on field(s) from the header file, which is usually the case.
3. Join the two files with a join logical. Run the OPNQRYF command over the join logical.
4. Join the two files with one OPNQRYF command.
In my opinion, option 1 is the worst. Option 2 is OK if you don't have to sort on fields from both files. I would use option 3 only if I had an existing join logical. That is, I wouldn't create a join logical just for this. Option 4 is good, but if the files are big, performance can get pretty bad. Keep in mind that options 3 and 4 won't work if you're updating the files. In your case, since you're reprinting invoices, I'd say option 2 is probably the way to go.
- Ted Holt





Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online