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



I'm guessing that 01 is the primary file's record id, 02 is the secondary file's id, and 03 is turned on if the two do not have identical contents.

01 and 02 will only turn on as each field is read into the input buffer; i.e., they cannot both be on at the same time. MR, though, will be turned on or off as each file is read.

Which means, in the case you sited, that all three out lines will be written:
OR 01 03,
OR 02 03, and
OR 03.

Since you don't actually have the POTATOE record until the secondary (02) file is read, you cannot legitimately have an 01 03 output line because the comparison would not have been legitimate.

Frankly, this kind of thing is difficult to do on detail cycle alone. The total cycle portion, though, is your friend. I.e., I would set a Level break on KeyField (L1):

C L1 Clear TempFields
C 01 MOVE Data Temp01
C 02 MOVE Data Temp02

CL1 compare Temp01 to Temp02 and print (I prefer EXCPT output here) the lines you want if they differ.


* Jerry C. Adams
*IBM System i Programmer/Analyst
B&W Wholesale Distributors, Inc.* *
voice
615.995.7024
fax
615.995.1201
email
jerry@xxxxxxxxxxxxxxx <mailto:jerry@xxxxxxxxxxxxxxx>



rob@xxxxxxxxx wrote:
Well I did my first Matching Records program from scratch. Kind of strange to see that sort of stuff with all free format calculations and stuff.
Pretty cool stuff for simple comparison between two files. My comments did warn people that you'll be delving into the RPG cycle and to put on your caveman suit. (Had to put that comment in there after I sent a program sample off to one prominent lister and it took him a while to catch that I had a primary file.)

I have a simple printing question. Goal is that if my columns look something like:

KeyField DataField File

MYKEY POTATO 01
POTATOE 02

KEY2 TOMATO 01

KEY3 CARROT 02

This would mean that MYKEY was in both files but there was a difference in the data field. KEY2 was only in the first file and KEY3 was only in the second file.
Working great only I am getting an extra blank line between POTATO and POTATOE. How do I eliminate that?

...
// If there is a local record, but no remote record, print it. (01 NMR)
// If there is a remote record, but no local record, print it. (02 NMR)
// If there are both but any of the fields do not match, print it. (03 MR)
...
O D 01NMR 1
O OR 01 03
O LKEYFIELD
O ' '
O LDATAFIELD
O ' 1'

O D 02NMR 1
O OR 02 03
O NMR RKEYFIELD
O ' '
O RDATAFIELD
O ' 2'

// Blank line to print after a pair of records.
O D 01NMR 1
O OR 02NMR
O OR 03
O ' '

Rob Berendt


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.