PCMPDBF Command for IBM ISeries AS/400 System i

Introduction

PCMPDBF compares records in two versions of same database (PF, LF) or DDM file. This is one of the commands in our ISeries utilities library (click this URL for full Prospero Software PSPUTIL contact and pricing details). This command is useful to compare before/after file contents. For example, following a system conversion or during a parallel run. It is a good tool for system testers and testing teams to test system results.

The compare is at field level. One record for every field difference is written to a results file PCMPDBRS - or your own copy of PCMPDBRS. PCMPDBRS has records with unmatched keys (on either version of the file) or - if keys match - has one record per different field value. If the file is not keyed, then the relative record number appears in the key field. The PCMPDBRS records include an audit date/time the record was created and the field type - A for Alphanumeric, P for Packed Decimal etc. You can develop your own query/report program to run over the PCMPDBRS member to select and format the results. For a sample of such a report, run the program PSPUTIL/PCMPDBFR - with a suitable OVRDBF to the member(s) in PCMPDBRS.

Fields can be ignored in the comparison e.g. a timestamp field that you know will be different in the two versions of a file you are comparing. This is achieved via the IGNFLD parameter on the PCMPDBF command - this allows up to 20 field names that will be ignored. You can also ignore field comparisons by selectively filtering the output records in the PCMPDBRS member.


Examples

PCMPDBF FILE1(GLDATA/GLMAST) MBR1(*FIRST) FILE2(GLDATAOLD/*FILE1) MBR2(*MBR1) MBRRS(GLDATA)

Command above compares first members in each of two versions of file GLMAST - one in GLDATA library, the other in GLDATAOLD library. Differences are written into the member GLDATA in the file PSPUTIL/PCMPDBRS - replacing any records already in that member.

PCMPDBF FILE1(GLDATA) MBR1(M1997) MBR2(M1998) RSFILE(MYLIB/PCMPGL) MBRRS(COMP9798) MBROPT(*ADD) IGNFLD(DTEAUD TIMAUD)

Command above compares members M1997 and M1998 in file GLDATA in *LIBL. Differences are appended to the member COMP9798 in the file MYLIB/PCMPGL (which is a clone of PCMPDBRS). PCMPDBF automatically creates MYLIB/PCMPGL if it does not already exist. The values of the DTEAUD and TIMAUD fields are ignored in the comparison.


Restrictions

1) External definition: FILE1 must be externally defined. It is analysed for record layout (key and non-key fields) and record length. FILE2 is assumed to have the same record layout and record length. So FILE2 does not have to be externally defined, as long as it has the same implicit record layout/length as FILE1.
2) The field names reported in PCMPDBRS are those in FILE1. If FILE2 has different field names, these do not appear in PCMPDBRS.
3) Single record format in FILE1 (FILE2 assumed to have same format).
4) Non-keyed files: Files do not have to be keyed. In this case, processing is simply by relative record number (RRN), which is the value that appears for the key in PCMPDBRS. If arrival sequence is a concern, you may need to sort the underlying records prior to running the command. To keep life simple, there is a restriction that MBR1 and MBR2 must have same number of records if not keyed.
5) Keyed files: Files do not have to be keyed unique, as long as you accept that records with the same key may not be compared exactly - arrival sequence is not predictable.
6) FILE1 and FILE2 do not have to be physical files or logical files. Either/both may also be a DDM file, in which case the MBR1 and MBR2 values on the PCMPDBF command are ignored. A DDM file itself has no members, although you may create it to point to selected member(s) in the file on the remote system.
7) Maximum 99 keys and 2048 fields with maximum record length of 4K (4096 bytes): These limitations can be bumped up quite easily if needs be.
8) PCMPDBRS results: For every field-level difference, a record is written to the PCMPDBRS member you select. This includes fields (e.g. RSAV1, RSAV2) that show the values that are different. For large field values it is difficult to show exactly where the difference occurs. So if you look at a PCMPDBRS record and do not see an obvious field difference, always examine the original files that are being compared to detect the actual difference. The difference does exist - PCMPDBRS may just not show it exactly.
9) Field types: The following DDS types are fully supported:
  • A (Alphanumeric)
  • P (Packed Decimal)
  • S (Zoned Decimal)
  • F (Floating Point)
  • L (Date)
  • T (Time)
  • Z (Timestamp)
DDS types B (Binary) and H (Hexadecimal) are supported, but with two restrictions:
  • A binary or hexadecimal field can not be a key field.
  • In the record in the PCMPDBRS results file, a different value for a a Binary field is reported in the RSAV1 and RSAV2 fields with the word *BIN and a different value for a hexadecimal field is reported with the word *HEX. This is done because there is no absolutely safe way to capture the binary/hexadecimal values (they could contain unprintable characters). You still see which record/field has the difference, but have to look in the original database files to find out the actual values that differ.
10) Field lengths: Alphanumeric fields (DDS type A) are limited to maximum 4096 characters. Numeric fields (DDS types P/S/F) are limited to maximum 15 decimal places and 29 digits in total.
11) Floating point numbers: If you use floating point fields (DDS type F) then you need to have a good understanding of how their numeric values are actually stored in your database files. Otherwise PCMPDBF may report a difference that you struggle to reconcile with your actual data.

PCMPDBRS Changes

The results file PCMPDBRS may change format in line with improvements to the PCMPDBF file. This has happened several times already:

11th September 2004: The field RSNV1 (30.9) was split into two fields RSNV1I (29.0) and RSNV1D (15.15) to record the integer (whole number) and decimal (fractional) values of numbers in your data. Similarly, the field RSNV2 (30.9) was split into two fields RSNV2I (29.0) and RSNV2D (15.15). This change means that the total size of any number in your data reported in the PCMPDBRS file is now 34 digits (29+15) - which you are extremely unlikely to exceed. The alphanumeric equivalent of these numbers is still shown in the RSAV1 and RSAV2 fields.

27th December 2007: Added the following fields to PCMPDBRS:

  • RSTYP for field type.
  • RSCMDT and RSCMTM for the CCYYMMDD date and HHMMSS time the compare was done i.e. system date/time the record was generated.
  • RSNVDI and RSNVDD to record the difference between RSNV1I/RSNV2I and RSNV1D/RSNV2D respectively.

11th May 2009: Rethought the way RSAV1 and RSAV2 values are reported for non-numeric fields. Your data values may be more than 50 characters long (the length of RSAV1/RSAV2), so some algorithm is required so you can see the difference in all circumstances. There was some slight inconsistency in this area in prior releases, so the final decision here is as follows:

  • If field <= 50 characters, show whole field values in RSAV1/RSAV2. User can visually inspect to see what characters are different.
  • If field > 50 characters, show in RSAV1/RSAV2 such that the first different character is in position 50 e.g. if first different character is in position 70, RSAV1 and RSAV2 show characters 20-70.
  • Introduce new field RSAVDP to record the position in the source data for the first different character e.g. has value '70' if the first different character is in position 70. This field is also populated for numeric fields, but in this case it records the position of the first different character in the RSAV1/RSAV2 fields, not the first different character in the source data - which may be in several formats such as packed, zoned or floating-point.

Every time the format of the PCMPDBRS file changes, you have to consider the impact on any current copies of PCMPDBRS you have - whether in the PSPUTIL library or another library. If you want to retain any data members in those old copies of PCMPDBRS, you have to replace the file with the new format file and then copy back those members with FMTOPT(*MAP *DROP). Installing the new release of PSPUTIL does not upgrade any old copies of PCMPDBRS automatically. If you accidentally run the new PCMPDBF command over the old-format PCMPDBRS file, the command will fail with a file level check.


IBM rebranded the AS/400 - some users called it AS400 - to ISeries several years ago and then to System i. All 4 names - ISeries, AS/400, AS400, System i - refer to exactly the same system.