× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Glenn,

As long as nobody else ever has to maintain this, good for you.
The way it is now, it's unreadable.
The next person would have to re-write this, wasting time to test and thus
introducing the chance of creating a bug unnecessarily.


Like others, I too found it very easy to understand. But then I also coded
plenty of MR programs in a previous life. If I reformat Terri's program
like this, does it help?

* Note use of RPG matching records logic. See in-line comments.
FGLD490C1 IPE AE Disk
FGLD490G1 ISE AE Disk

D MatchExists S N
D ReadingC S N
D ReadingG S N

* List of fields for RPG to "match". Data in each file must
* be ordered by the match fields by virtue of access paths
* or OPNQRYF or similar.
IGLD490C1r 01
I CYEAR M1
I CPERD M2
I CPROD M3
IGLD490G1r 02
I GYEAR M1
I GPERD M2
I GPROD M3

C/Free
If First = 'YES';
Exsr Init;
Endif;

// RPG matching record logic automagically decides whether to read
from
// the primary or secondary file(s) so all records get processed
// sequentially as if a full outer join. Note that if identical
values
// exist in both files (*InMR), the primary is read one cycle and
the
// secondary the next, so when a "match" occurs we wait until
processing
// the secondary yielding data from both files being available.

// Make readable versions of the indicators used by MR logic
ReadingC = *In01;
ReadingG = *IN02;
MatchExists = *InMR;

// Decide how to process the current record
Select;
When ReadingC and MatchExists;
// Do nothing. Wait until matching G record read.

When ReadingG and MatchExists and CCST = GCST;
// Do nothing. Item in both files & amounts match.

When ReadingG and MatchExists;
Exsr AmountsDiffer;

When ReadingC and NOT MatchExists;
Exsr UnmatchedC;

When ReadingG and NOT MatchExists;
Exsr UnmatchedG;
Endsl;
/End-free

Personally, I would have used *InzSR instead of variable First above, but
that's another implicit vs explicit debate. I also dropped out the IF test
to make sure either *IN01 or *IN02 were on because, as coded, it would
always be true. The only way it would not be is if there were additional
secondary files, or either of the two existing files had multiple record
formats. Neither appears to apply here. I also added a spurious WHEN
clause which does nothing except help a future maintenance programmer
understand the combination of primary record with a match was not left out
unintentionally but indeed has nothing we need to do.

The thing about the MR logic cycle is that it works, and works VERY well.
Invariably, when I see code where somebody has tried to do the same thing
themselves using full procedural files, it is always more convoluted and you
have to study the code to see if in fact it does what it claims to do. This
is especially true when you add the concept of level breaks, and want to
have the data fields in records still available during "total time" before
they get overlaid by reading the values which caused the level break.


Doug

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.