× 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.



If only there was some tool or technique that would process sequential
files like this. And if the tool or technique had the same initials as
one of the greatest RPG programmers of all time, well, that would just
be better.

On Dec 21, 2007 10:30 AM, Murphy, Mark <MurphyM@xxxxxxxxxx> wrote:
Seems to be getting less trivial all the time.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joep
Beckeringh
Sent: Thursday, December 20, 2007 6:05 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Matching Records - End Product

Still not safe. The first when-clause needs to be conditioned by 'not
%eof(file1) and not %eof(file2)'. If either file hits eof, the fields
still contain the value of the last record read.

And then there's the sequence of the records. The code assumes the
records are read in ascending order by key. If that is not the case ....
The cycle checks it (runtime error: 'Match field out of sequence').

But the point is made: writing your own matching records logic is
trivial. Sort of :-)

Joep Beckeringh


Murphy, Mark schreef:
These are both very nice, but they won't work unless the last record in both files is a matching
record. So you have to add some complexity to prevent an infinite loop in all but one circumstance.


/free
read file1;
read file2;
dow (not %eof(file1) or not %eof(file2));
select;
when old.key = new.key;
update file1; //matched records logic...
read file1;
read file2;
when (old.key < new.key and not %eof(file1))
or %eof(file2);
delete file1; // old file record no longer needed.
read file1;
other; // (old.key > new.key and not %eof(file2))
// or %eof(file1) = New record!
write file1; // using file2 fields
read file2;
endsl;
enddo;
*inlr = *on;
/end-free

You don't have to deal with that for MR logic. Now try making it work for three files. The
complexity increases exponentially. But not with MR logic. With MR logic you have a predefined
behavior that works the same whether you are matching records from two files or three or more. If
you
are looking for a different behavior, then you will have to code it yourself. Do you really want to
code it if you don't have to?

BTW, this really won't give you the same progression of records as MR logic. If there are record
formats involved that do not include match fields this won't work, but even if all record formats
have
match fields you could get something different. MR logic will select one record at a time for
processing, and the match fields do not have to be primary key fields. This means that each match
can
be found on multiple records of both files. Reading both files each time there is a match can
result
in a much different record progression than what you get with MR logic.

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


This e-mail transmission contains information that is intended to be confidential and privileged. If you receive this e-mail and you are not a named addressee you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this communication without the consent of the sender and that doing so is prohibited and may be unlawful. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please delete and otherwise erase it and any attachments from your computer system. Your assistance in correcting this error is appreciated.
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.