Compare physical file data

15 pts.
Tags:
Comparing Physical File Data
IBM iSeries
Physical File
Hi, I am trying to compare data from two different physical files. Both the files are in the same format but from two different systems. I need a report or a file which compares the data in both the files and report the differences in a report or a physical file. Any toughts on this. I already tried the CMPPFM and TAATOOL CMPDBF but both didnt worked out.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Well it sounds like you’ll need to write a program — RPG?
Assuming that the files are keyed
You’re looking at what we used to call a two file record matching process

read file a
read file b
loop
if keys are the same
if differences exist report
read file a
read file b
if filea key is less than file b
report file a
read file a
else
report file b
read file b

continue until eof of either
report rest of the other.

If they are not keyed then sort the files.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • PY
    Hi, with the wrkQry you can do that. Just define those two files in that and common fields, if there is any difference it picks up all those records in the Query. Let me know if you need more info on this.
    60 pointsBadges:
    report
  • Gilly400
    Hi, You say CMPPFM didn't work out. In what way ? Is it because the files are physically on 2 different systems ? I have a tool for using CMPPFM between systems - unfortunately it needs to copy the file to the local system using DDM so it's not quick if you have big files. CMD Source
                 CMD        PROMPT('Compare remote member')                  
                                                                             
                 PARM       KWD(LCLFILE) TYPE(QUAL1) MIN(1) +                
                              PROMPT('Local file')                           
                 PARM       KWD(LCLMBR) TYPE(*CHAR) LEN(10) MIN(1) +         
                              PROMPT('Local member name')                    
                                                                             
                 PARM       KWD(RMTFILE) TYPE(QUAL2) MIN(1) +                
                              PROMPT('Remote file')                          
                 PARM       KWD(RMTMBR) TYPE(*CHAR) LEN(10) MIN(1) +         
                              PROMPT('Remote member name')                   
                                                                             
                 PARM       KWD(SYSTEM) TYPE(*CHAR) LEN(15) MIN(1) +         
                              PROMPT('System name or IP address')            
                                                                             
                 PARM       KWD(CMPTYPE) TYPE(*CHAR) LEN(5) RSTD(*YES) +     
                              DFT(*LINE) VALUES(*LINE *FILE *WORD) +         
                              PROMPT('Compare type')                         
                                                                             
                 PARM       KWD(RPTTYPE) TYPE(*CHAR) LEN(8) RSTD(*YES) +     
                              DFT(*DIFF) VALUES(*DIFF *SUMMARY *CHANGE +     
                              *DETAIL) PROMPT('Report type')                 
                                                                                   
                 PARM       KWD(OUTPUT) TYPE(*CHAR) LEN(8) RSTD(*YES) +            
                              DFT(*) VALUES(* *PRINT *OUTFILE) +                   
                              PROMPT('Output')                                     
                                                                                   
                 PARM       KWD(OUTFILE) TYPE(QUAL3) PROMPT('Output file')         
                                                                                   
     QUAL1:      QUAL       TYPE(*NAME) LEN(10) MIN(1)                             
                 QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +                       
                              SPCVAL((*CURLIB) (*LIBL)) PROMPT('Library')          
     QUAL2:      QUAL       TYPE(*NAME) LEN(10) MIN(1)                             
                 QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +                       
                              SPCVAL((*CURLIB) (*LIBL)) PROMPT('Remote Library')   
     QUAL3:      QUAL       TYPE(*NAME) LEN(10)                                    
                 QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +                       
                              SPCVAL((*CURLIB) (*LIBL)) PROMPT('Library')          
    
    CL Source
                 PGM        PARM(&QUAL1 &LCLMBR &QUAL2 &RMTMBR &SYSTEM +   
                              &CMPTYPE &RPTTYPE &OUTPUT &QUAL3)            
                                                                           
                 DCL        VAR(&QUAL1)      TYPE(*CHAR) LEN(20)           
                 DCL        VAR(&LCLLIB)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&LCLFIL)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&LCLMBR)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&QUAL2)      TYPE(*CHAR) LEN(20)           
                 DCL        VAR(&RMTLIB)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&RMTFIL)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&RMTMBR)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&SYSTEM)     TYPE(*CHAR) LEN(15)           
                 DCL        VAR(&CMPTYPE)    TYPE(*CHAR) LEN(5)            
                 DCL        VAR(&RPTTYPE)    TYPE(*CHAR) LEN(8)            
                 DCL        VAR(&OUTPUT)     TYPE(*CHAR) LEN(8)            
                 DCL        VAR(&QUAL3)      TYPE(*CHAR) LEN(20)           
                 DCL        VAR(&OUTFIL)     TYPE(*CHAR) LEN(10)           
                 DCL        VAR(&OUTLIB)     TYPE(*CHAR) LEN(10)           
                                                                           
                 DCL        VAR(&QUALRMTFIL) TYPE(*CHAR) LEN(40)           
                                                                           
                 DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(512)              
                 DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)    
                 DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)               
                 DCL        VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)            
                                                                         
                 MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))      
                                                                         
                 CHGVAR     VAR(&LCLFIL) VALUE(%SST(&QUAL1 1 10))        
                 CHGVAR     VAR(&LCLLIB) VALUE(%SST(&QUAL1 11 10))       
                                                                         
                 CHGVAR     VAR(&RMTFIL) VALUE(%SST(&QUAL2 1 10))        
                 CHGVAR     VAR(&RMTLIB) VALUE(%SST(&QUAL2 11 10))       
                                                                         
                 CHGVAR     VAR(&OUTFIL) VALUE(%SST(&QUAL3 1 10))        
                 CHGVAR     VAR(&OUTLIB) VALUE(%SST(&QUAL3 11 10))       
                                                                         
                 CHGVAR     VAR(&QUALRMTFIL) VALUE(&RMTLIB *TCAT '/' +   
                              *TCAT &RMTFIL *TCAT '(' *TCAT &RMTMBR +    
                              *TCAT ')')                                 
                                                                         
                 DLTF       FILE(QTEMP/CMPRMTMBR)                        
                 MONMSG     MSGID(CPF0000)                               
                 DLTF       FILE(QTEMP/CMPRMTMBRX)                       
                 MONMSG     MSGID(CPF0000)                               
                                                                         
                 CRTDDMF    FILE(QTEMP/CMPRMTMBR) RMTFILE(*NONSTD +      
                              &QUALRMTFIL) RMTLOCNAME(&SYSTEM) +           
                              TEXT('Compare Remote Members DDMFile')       
                                                                           
                 CPYF       FROMFILE(QTEMP/CMPRMTMBR) +                    
                              TOFILE(QTEMP/CMPRMTMBRX) FROMMBR(&RMTMBR) +  
                              TOMBR(&RMTMBR) CRTFILE(*YES)                 
                                                                           
                 IF         COND(&OUTPUT ¬= '*OUTFILE') THEN(DO)           
                 CMPPFM     NEWFILE(&LCLLIB/&LCLFIL) NEWMBR(&LCLMBR) +     
                              OLDFILE(QTEMP/CMPRMTMBRX) OLDMBR(*FIRST) +   
                              CMPTYPE(&CMPTYPE) RPTTYPE(&RPTTYPE) +        
                              OUTPUT(&OUTPUT)                              
                 ENDDO                                                     
                                                                           
                 IF         COND(&OUTPUT = '*OUTFILE') THEN(DO)            
                 CMPPFM     NEWFILE(&LCLLIB/&LCLFIL) NEWMBR(&LCLMBR) +     
                              OLDFILE(QTEMP/CMPRMTMBRX) OLDMBR(*FIRST) +   
                              CMPTYPE(&CMPTYPE) RPTTYPE(&RPTTYPE) +        
                              OUTPUT(&OUTPUT) OUTFILE(&OUTLIB/&OUTFIL)     
                 ENDDO                                                     
                                                                           
                 DLTF       FILE(QTEMP/CMPRMTMBR)                          
                 MONMSG     MSGID(CPF0000)                                 
                 DLTF       FILE(QTEMP/CMPRMTMBRX)
                 MONMSG     MSGID(CPF0000)                                  
                                                                            
                 GOTO       CMDLBL(ENDPGM)                                  
                                                                            
    ERROR:                                                                  
                 RCVMSG     MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID) +  
                              MSGF(&MSGF) MSGFLIB(&MSGFLIB)                 
                 SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +            
                              MSGDTA(&MSGDTA)                               
                                                                            
    ENDPGM:                                                                 
                 ENDPGM                                                     
    
    Hope this helps... Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • Reachme
    Badically I was trying to compare the object and source change dates on two different systems. I did a DSPOBJD on both the systems and got the two files on the same system using NetFile transfer. Now I need to compare the two files. I tried CMPPFM but it is returning me lots of junk values like some special characters.
    15 pointsBadges:
    report
  • philpl1jb
    That's entirely different. Something like Query should do it. Only one problem if your looking for object in either list that don't exist in the other then you will need two queries.
    51,355 pointsBadges:
    report
  • Gilly400
    Hi, If you have 2 files output from DSPOBJD and need to compare the object and source change dates, then Query is going to be the way to go. CMPPFM is for comparing the raw data in the file, it doesn't take into account field names in the way that you want. Create a query, use WRKQRY - option 1. In file selections specify both your DSPOBJD files (use F9 to add the second file). Specify matched records (this will join the records from one file to the other). For the fields used to join, specify T01.ODLBNM EQ T02.ODLBNM and T01.ODOBNM EQ T02.ODOBNM. In select and sequence fields, choose the fields that you want to see from both DSPOBJD files. I would suggest the following :- T01.ODLBNM T01.ODOBNM T01.ODOBTP T01.ODOBAT T01.ODOBTX T01.ODSRCD T01.ODSRCT T01.ODLDAT T01.ODLTIM T02.ODSRCD T02.ODSRCT T02.ODLDAT T02.ODLTIM Then specify your record selections, something like this should give every non matching object/source date/time :-
           T01.ODSRCD        NE     T01.ODSRCD
    OR     T01.ODSRCT        NE     T01.ODSRCT
    OR     T01.ODLDAT        NE     T01.ODLDAT
    OR     T01.ODLTIM        NE     T01.ODLTIM
    
    Set your output type to be display or printer or file (whichever you want). and run the query... Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • DanD
    I suspect your are doing this to verify your production objects match the source change date. You will need member information from the source files so do DSPFD *MBRLIST to an outfile and dspobd of your pgm objects to an outfile and query using member name to match pgm name then compare last change date for the member vs. creation date for the objects.......if that's what you're trying to accomplish.
    2,865 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following