TechTalk: Running OPNQRYF over a multiformat logical file.

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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

TED HOLT

Ted Holt is IT manager of Manufacturing Systems Development for Day-Brite Capri Omega, a manufacturer of lighting fixtures in Tupelo, Mississippi. He has worked in the information processing industry since 1981 and is the author or co-author of seven books. 


MC Press books written by Ted Holt available now on the MC Press Bookstore.

Complete CL: Fifth Edition Complete CL: Fifth Edition
Become a CL guru and fully leverage the abilities of your system.
List Price $79.95

Now On Sale

Complete CL: Sixth Edition Complete CL: Sixth Edition
Now fully updated! Get the master guide to Control Language programming.
List Price $79.95

Now On Sale

IBM i5/iSeries Primer IBM i5/iSeries Primer
Check out the ultimate resource and “must-have” guide for every professional working with the i5/iSeries.
List Price $99.95

Now On Sale

Qshell for iSeries Qshell for iSeries
Check out this Unix-style shell and utilities command interface for OS/400.
List Price $79.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA 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.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra 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: