View Full Version : help with a primary file(RPGII)
Guest.Visitor
01-01-1995, 02:00 AM
Hi I have a program that uses a primary file. It's all written in RPGII. I need to know how to make it read the next record if it doesn't meet a code#. Another newbie question. Can I use just a read and then the file name? Here's an example of what I need to do. svrcde IFEQ 40502684 READ CHARGE ENDIF any help would be really really appreciated Frank
D.Handy
06-28-2000, 12:18 PM
Frank, <font color=blue>Can I use just a read and then the file name? </font> No. You must let the cycle take its course and read the next record implicitly. Typical RPG II method here would be to add a TAG as the very last "detail time" calc; perhaps called END or whatever. Then in your IF block do a GOTO END to skip over the remaining detail time processing. For GOTO-less code you could reverse the IF test, and move the END of the IF block past the remaining processing so it is all conditioned on the opposite test. In this case, I'd recommend moving the other processing to a subroutine so you could keep the IF and END close to each other. Caveat: Watch out for anything happening at "detail output" time. If the O specs have any Detail records, check the conditioning indicators. It may be necessary to SETOF a record identifying indicator or add additional conditions. Doug
B.Myrick
06-28-2000, 12:23 PM
Frank, A primary file can only be read by the compiler. That is at the beginning of each cycle. To access another record within the cycle, you would have to condition a goto/tag which goes to the END of the calcs, allowing the program to get the next record. This would entail using a bunch of indicators/tags if you want to stay within a loop in the program. Yuck! My suggestion is to change primary file to a fully procedureal one. Then at the top of the program C-specs, perform a READ on the file, with and EOF indicator in the LO position. You can also use LR as your READ indicator which will allow you to end the program without adding code to set on LR. The primary file when read, will turn on LR automagically. FFILENAME IP F DISK change to FFILENAME IF F DISK Add *** C READ FILENAME LR This will set on LR and allow you to use calcs such as.... CLR Code of your choice here CLR more code CLR you get the idea.... Hope this helps, Bret
David Abramowitz
06-28-2000, 02:37 PM
If you code number is one character, you can define a record type on the "I" specs that excludes that record - or - You could use a comparison at the beginning of the "C" specs, and if the code is found branch to the end of the "C" specs, conditioning output not to do anything. Dave
Guest.Visitor
07-03-2000, 09:54 AM
One caution in changing a file from Primary to 'Full Procedural' in RPGII. If this report does any sort of output (more than likely) it is probably using Level breaks and H, D, and T type output specs. These cannot be used with a full procedural file and must be converted to calculation specifications and exception output. John P
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.