Oh, Alan, Alan, Alan... what a can of worms you've opened! (:
RPG stands for Report Program Generator. It is assumed that you want
to use all of the files you have listed, or they wouldn't be listed
in the first place, so the machine opens them for you. Unless you
condition the F specs with the 'user controlled' option, all files
are opened when the program starts, and closed when the program ends.
No need to trouble your mind with the details-- that's what the
system's there for!
The Cycle uses the old HIPO logic: Hierarchy-- Input / Processing /
Output. So, the system will read a record for you and present the
data to you for processing. You then manipulate things, and make
data ready for output. The system 'puts' the records you specify,
then makes another record ready for your use. No need to fiddle with
DOWHILE and DOUNTIL logic; no need to worry about where is the best
place to locate the "prime the pump" read-- in the loop or outside.
*INZSR isn't needed. You condition Detail Calculations using the 1P
indicator if you want things initialized.
Lessee-- Matching Record logic in 10 minutes...
The fields you define with the Matching Field Indicators should be in
1-to-1 correspondence with the key fields on the files being matched,
and with the Level Indicators.
Once the indicators and key fields are aligned, Matching Record logic
reads multiple files as if they were merged into a single file sorted
by the Matching Fields. Period. Think "Join Logical."
The primary file is read first if both a primary and secondary
"match." If you have multiple secondary files that match, the
records are presented one-at-a-time. The Record Resulting Indicators
you specified tell you which record is available for your use.
That's it. And the Matching Indicators turn on to indicate which
2ndary file fields 'match' the primary.
RPG easy? You bet! You just have to let the system do the grunt
work so you can concentrate on the calculations!
--Paul E Musselman
PaulMmn@xxxxxxxxxxxxxxxxxxxx
PS-- back when I wrote COBOL programs, I used to code using the RPG
Cycle as my guide for correct logic. Worked beautifully, and no
tangled mess of logic!
PPS-- WAY back when (ca. 1973) IBM's old Data Processing Division
had a learn-it-yourself RPG course. It had a book and a 7" reel of
tape. In about 2 hours it taught the basics of the RPG cycle so you
could write a "hello, world" program. If anyone has a copy of this
beauty, it ranks right up there with Radio Shack's first
learn-it-yourself BASIC manual. Simple, Elegant, not a lot of
details, but you were off and running in just a few hours.
PPPS-- Anyone else remember Chaining using the Extension specs? I
never did it, but I did trip across a few programs at my first job
that did.
At 12:09 AM -0400 8/25/07, Alan- wrote:
> The cycle is NOT easy to learn. Not a one of you found it
intuitive when you
first learned it. It is only now that you know it that it is "easy".
Teach me Matching Records in 10 minutes. Where does *INZSR get called? Why
are the files getting opened without me opening them - show me where in my
code that is happening?
Easy - pah!
Free format RPG - now THAT is easy.
>
As an Amazon Associate we earn from qualifying purchases.