Problem solve Get help with specific problems with your technologies, process and projects.

Merge two keyed physical files

This utility gets around having to copy together two files that are the same and have duplicate keys.

I have created a utility that will merge any two keyed physical files on the AS/400 or iSeries. This is something that will get around copying together two files that are the same and have duplicate keys.

This utility uses a psuedo type of AI, as it figures out what the keys are for the file, creates an RPG program on the fly, compiles it and executes it to merge the two files. It has saved us many times when wanting to update a file with data but also save the old or new depending on which is the receiving library.

This utility uses a prompt screen that allows the user to only have to type in the file name and the From and To library name and press F6 to submit the job. Presto Mergeo -- and it is done.

Below are links for PDF documents for each source and one Word document needed for the Message file that needs to be set up.

The program MRGFILR1 is the Prompt screen program. This is where the user types in the file name and the From and To library. Most everything is self-explanatory on how to use it and what it does.

Just setup the source and compile, the MRGSKEL cannot be compiled, as it is what is used to create the program on the fly and it is commented to that fact.

Here is the PDM list of objects:

CMSGLE           CLLE        Merge 2 files: Clear MSGQ (Message Queue)     
MRGCKFLCL      CLP         Merge 2 files: Check if valid File/Library    
MRGCMPL        CLP         Merge 2 files: Compile created program        
MRGCRTCL       CLP         Merge 2 files: Create RPGLE program on the fly
MRGFILDF        DSPF        Merge 2 files: Display file                   
MRGFILECL       CLP         Merge 2 files: Run complete process           
MRGFILR1        RPGLE      Merge 2 files: Prompt                         
MRGGENPGM   RPGLE      Merge 2 files: Create RPGLE program from Skel 
MRGSKEL        RPGLE       Merge 2 files: Skeleton Merge program NO COMPILE
MRGSUBMIT    CLP          Merge 2 files: Submit Merge                      
SMSGLE          CLLE         Merge 2 files: Send message to (Message Queue)   

Have fun.

Source files and Word document


Dig Deeper on iSeries CL programming