MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need to generate a comparison report between two files

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Thu Apr 23, 2009 12:24 pm    Post subject: Need to generate a comparison report between two files Reply with quote

I was going through below mentioned post and I have similar requirements to compare 2 file and generate report of differences.

http://www.mvsforums.com/helpboards/viewtopic.php?t=10459&highlight=compare


I am trying to understand logic here in steps? Could someone please explain logic so that I can modify this solution for different requirement?

The points I am looking for are :
1) What if I am looking for differences in multiple fields?
2) Is it possible to track changes in multiple fields?


Thanks,
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 23, 2009 12:58 pm    Post subject: Reply with quote

Sqlcode,

which solution are you referring to?

Either way why don't you post a sample input and desired output along with DCB properties?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 23, 2009 1:00 pm    Post subject: Reply with quote

Sqlcode,

which solution are you referring to?

Either way why don't you post a sample input and desired output along with DCB properties?

You can match multiple fields , you can concatenate all the fields you want to compare as a single string and then compare it

or you can check each field individually
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Thu Apr 23, 2009 1:15 pm    Post subject: Reply with quote

I am referring to DFSORT solution.


KEY FIELDS & THEIR DATA TYPES ALONG WITH POSITION
Code:

ID                      Amount                       STAGE-1            STAGE-2       
S9(12) COMP-3           S9(07)V99 COMP-3             CHAR(5)            CHAR(5)         
POS: 23-29              POS:402-406               POS:542-546      POS:547-551   
------------------------------------------------------------------------------------------------



1. LRECL 1000 and RECFM =FB.
2. Key is unique in both the files.

Fields to be reported for change.

Code:

FLAG-1                                FLAG-2
CHAR(1)                               CHAR(1)
POS:101-101                           POS:102-102
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 23, 2009 3:50 pm    Post subject: Reply with quote

Sqlcode,

The following DFSORT JCL will give you the desired results.

I used these codes to denote the changes


Code:

NC  = No Change ie. ID,AMOUNT,STAGE-1,STAGE-2 all match
CR  = Change record i.e id matches but one of AMOUNT,STAGE-1,STAGE-2 doesnt match
NA  = New Add ie no matching key in file 2
ND  = New Delete i.e No matching key in file 1


The logic is quite simple

1. Put a header so as to identify from which file the record came from. Use group function to put a ID in pos 1017.

2. Now if it is from file 2 we put the contents of amount, stage1 and stage-2 in pos 1001.

3. Now sort on the key

4. Sum the contents in pos 1001 and also the ID

5. If there is a match key record the sum will be 3 and now we can compare the 2 records
6. If they dont match the sum will be either 1 or 2. if 1 then it is from file 1 and if 2 then it is from file 2.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=1000 byte header record,DISP=SHR
//         DD DSN=1000 byte input file1,DISP=SHR
//         DD DSN=1000 byte header record,DISP=SHR
//         DD DSN=1000 byte input file2,DISP=SHR
//SORTOUT  DD SYSOUT=*                                             
  OPTION EQUALS                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:16Z)),                     
  IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),PUSH=(1017:ID=1)),
  IFTHEN=(WHEN=(1017,1,ZD,EQ,2),OVERLAY=(1001:402,5,542,10))       
  SORT FIELDS=(023,7,PD,A)                                         
  SUM FIELDS=(1001,8,BI,                                           
              1009,8,BI,                                           
              1017,1,ZD)                                           
  OUTFIL IFOUTLEN=1000,OMIT=(1,6,CH,EQ,C'HEADER'),                 
  IFTHEN=(WHEN=(1017,1,ZD,EQ,1),OVERLAY=(101:C'NA')),               
  IFTHEN=(WHEN=(1017,1,ZD,EQ,2),OVERLAY=(101:C'ND')),               
  IFTHEN=(WHEN=(1017,1,ZD,EQ,3,AND,                                 
                0402,5,PD,EQ,1001,5,PD,AND,                         
                0542,5,CH,EQ,1006,5,CH,AND,                         
                0547,5,CH,EQ,1011,5,CH),                           
  OVERLAY=(101:C'NC')),                                             
  IFTHEN=(WHEN=(1017,1,ZD,EQ,3,AND,                                 
                0402,5,PD,NE,1001,5,PD,OR,                         
                0542,5,CH,NE,1006,5,CH,OR,                         
                0547,5,CH,NE,1011,5,CH),                           
  OVERLAY=(101:C'CR'))                                             
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group