Generic File Merge

The program can be run on any two files with identical file layouts and keys. This will run without any table configuration at all. The key needs to be unique. The program sorts the files based upon the specified key fields, performs whatever actions are necessary to synchronise them.

The business need driving the creation of the program came out of Role Based Security. Nightly, we aggregate security for each individual, based upon what roles are assigned to that individual. While, for most files, we can update the underlying security files, this was not possible for JDEdwards Business Unit (i.e., row) Security (the reasons for which are beyond the scope of what we're dealing with here). For Business Unit Security, we need to clear the file and rebuild it. Unfortunately, management wants the files journalled. We had large quantities of journal receivers containing very little information. So, we built the new files in a temporary file, and merged the changes into the production file.

The program is called from the command line with the following parameters:

The program call looks like this:

call cp1020c (DTAPRD F0001 *FIRST DTAQUA F0001 *FIRST')

There is no output. If output is desired, then CP1030 can be modified (with three (3) lines of code) to perform the merge.

Sometimes we are not interested in comparing *every* field in the file. Audit fields (date created, etc., come to mind). For every field to be excluded, add a record to the file CP1020F. The following is an example when loaded for F0001:

 AFRECTYP    AFFLDNAM 
 ----------  ----------                       
 F0001       MSUSER                          
 F0001       MSPID                           
 F0001       MSUPMJ                          
 F0001       MSUPMT                          
 F0001       MSJOBN                         

The key field is the same as the First File Name.


The following link takes you to the source code, written in beautiful /free ILE/RPG. This source is distributed under a creative commons license.

cp1020.txt - Generic File Merge




Valid HTML 3.2! Creative Commons License

BrilligWare/ chris@pando.org / revised October 2010