Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CMPPFM to Compare Data

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
Hello. I understand that CMPPFM is used mostly to compare source members, but I saw an article on the net that says you can use it to compare data in physical files. The article never stated how to do this however. I'd like to use it to compare data output from a specific program so that when changes are made to the program, the new and old output can be compared to verify that the changes made to the program are correct. However, when I used CMPPFM to compare two physical files, I get garbage output, such as:

I - -ë Ñ| b± ɬ Ë N
D - -ë Ñ| b± É" Ë N

Does anyone know how to use this command to compare records between two physical files containing data, not source code?
 
From the command help:

Code:
This command allows you to compare [b]source[/b] physical file members.

I don't think you can use it to compare a database file, unless it has no packed numerics.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
I saw that hint, and tried it, and I could not, for the life of me, see how it works. I get the same results as you. That command is designed for source members.

Personally, I would journal the file or use a trigger program on the file to audit any changes.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
Journal the file? How would you do this and how would this help me compare the files? I'm not sure that a trigger file would work because I'm going to be using two entirely different output files. Say for instance I run my program and get my output file. I then make some changes to the program and run it again to get a second output file after backing up the first one. THEN I want to compare the differences. I don't see how a trigger program would help me here.
 
With a trigger on the files, at least you only get changed records. It all depends on what you want to accomplish. Things get more complicated if one version of your program is adding records and the other one is not.

For a simple comparison (assuming you are just updating the file or adding the same stuff to a file), I would write an RPG program to compare the records. Use externally-defined data data structure, the PREFIX keyword, and the EXTFILE and/or EXTMBR keywords to keep your information separate. Read both your files. Copy them into the data structures. If the data structures are not the same, then go through each field and print the differences out.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
I don't think the trigger is going to work because the output file is cleared before every run. A back is made of the file.

An RPG program can work, but the best way would be to chain out to the second file to see if the record exists. However, this is a problem because I'd want to compare every field, and to have a logical file with a key for every field would be very bad on performance. Another option would be to read a record in the first file, then manually check every single record in the second file until it is found or not found. This would also be very bad on performance, unless the records are similar in both files (in terms of how they line up according to RRNs).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top