IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparing two file of same record length


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Wed Sep 05, 2007 4:17 pm
Reply with quote

Hi,

Is it possible to compare two files.
My requirement is i had two files of same record length.
First i need to check whether the number of records in both the files is same or not.
If the record count is same then i should validate the key field in both the files that starts from 5 to 10 position.
Can i do this.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Sep 05, 2007 6:51 pm
Reply with quote

Quote:
i should validate the key field in both the files that starts from 5 to 10 position

Please provide the sample input/output and more explanation in how to validate the key fields in both the files.
Whether you need a line to line comparision with key fields or looking for match of key in file 1 in file2 of one of the records.
In output whether you want only matched key records or non-matched key records or both in separate files.
Whether your key fields contains the unique values or not.

Following is the code to check for count match or not.
Code:
//S1 EXEC PGM=ICETOOL                       
//DFSMSG DD SYSOUT=*                         
//TOOLMSG DD SYSOUT=*                       
//FILE1 DD ...                                 
//FILE2 DD ...                                 
//T1 DD DSN=&&T1,DISP=(MOD,PASS)             
//T2 DD DSN=&&T2,DISP=(NEW,PASS)             
//TOOLIN DD *                               
 COPY FROM(FILE1) TO(T1) USING(CTL1)         
 COPY FROM(FILE2) TO(T1) USING(CTL2)         
 SELECT FROM(T1) TO(T2) ON(27,8,CH) ALLDUPS 
/*                                           
//CTL1CNTL DD *                             
 OUTFIL NODETAIL,REMOVECC,                                     
 TRAILER1=(C'COUNT OF RECORDS IN FILE1 ',COUNT=(M11,LENGTH=8))
/*                                                             
//CTL2CNTL DD *                                               
 OUTFIL NODETAIL,REMOVECC,                                     
 TRAILER1=(C'COUNT OF RECORDS IN FILE2 ',COUNT=(M11,LENGTH=8))
/*                                                             
// EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                           
//T1 DD DSN=*.S1.T1,DISP=(OLD,PASS)                           
//SORTIN DD DSN=&&T2,DISP=(OLD,DELETE)                         
//SORTOUT DD DUMMY                                             
//SYSIN DD *                                                   
 OPTION COPY,NULLOUT=RC4                                       
/*                                                             
// IF (RC=4) THEN                                             
// EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                           
*********COUNT NOT MATCH**********       
/*                                       
// DD DSN=*.S1.T1,DISP=(OLD,DELETE)     
//SORTOUT DD SYSOUT=*                   
//SYSIN DD *                             
 OPTION COPY                             
/*                                       
// ELSE                                 
// IF (RC=0) THEN                       
// EXEC PGM=SORT                         
//SYSOUT DD SYSOUT=*                     
//SORTIN DD *                           
***********COUNT MATCH************       
/*                                       
// DD DSN=*.S1.T1,DISP=(OLD,DELETE)     
//SORTOUT DD SYSOUT=*                   
//SYSIN DD *                             
 OPTION COPY
/*           
// ENDIF     
// ENDIF     
//   
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Wed Sep 05, 2007 7:33 pm
Reply with quote

Hi,
Here the explanation.
I had a input file of record length 80 with 1000 records. And the key field is from 5 to 10. After processing the job a output file will be generated which is of same record length and same key by updating one of the field. Here my input and output files will be using same copybook.
The main intention is i want to check whether the records provided in the input are there in the output or not. Thats why i am validating the record count and record key of my input and output file.
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Wed Sep 05, 2007 9:58 pm
Reply with quote

some more information is here.

both the files will be in sorted order only
i need line by line comparision with key fields
and i need output of matched and non-matched records seperate files
and the key fileds contain unique values

my input file:
amex100001bhaskar300.00..........( ).....

my output file:
amex100001bhaskar300.00..........(yes)....
initially the field with () will be blank in the input file. it will be updated with values in the output file.

So here i want to compare the key field that starts from 5 to 10
ie. 100001 and also number of records should be same
all the records that i passed as input should be present in the output.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Sep 06, 2007 3:02 pm
Reply with quote

Input:
FILE1
Code:
    AAAAAA
    BBBBBB
    CCCCCC
    EEEEEE
    FFFFFF
    111111
    222222
    444444
    555555
    999999

FILE2
Code:
    AAAAAA
    BBBBBB
    DDDDDD
    EEEEEE
    FFFFFF
    111111
    333333
    444444
    666666
    777777

Job:
Code:
//S1 EXEC PGM=ICETOOL                                           
//DFSMSG DD SYSOUT=*                                             
//TOOLMSG DD SYSOUT=*                                           
//FILE1 DD DSN=FILE1,DISP=OLD                   
//FILE2 DD DSN=FILE2,DISP=OLD                   
//T1 DD DSN=&&T1,DISP=(MOD,PASS)                                 
//T2 DD DSN=&&T2,DISP=(NEW,PASS)                                 
//TOOLIN DD *                                                   
 COPY FROM(FILE1) TO(T1) USING(CTL1)                             
 COPY FROM(FILE2) TO(T1) USING(CTL2)                             
 SELECT FROM(T1) TO(T2) ON(27,8,CH) ALLDUPS                     
/*                                                               
//CTL1CNTL DD *                                                 
 OUTFIL NODETAIL,REMOVECC,                                       
 TRAILER1=(C'COUNT OF RECORDS IN FILE1 ',COUNT=(M11,LENGTH=8))   
/*                                                               
//CTL2CNTL DD *                                                 
 OUTFIL NODETAIL,REMOVECC,                                       
 TRAILER1=(C'COUNT OF RECORDS IN FILE2 ',COUNT=(M11,LENGTH=8)) 
/*                                                             
// EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                           
//T1 DD DSN=*.S1.T1,DISP=(OLD,PASS)                             
//SORTIN DD DSN=&&T2,DISP=(OLD,DELETE)                         
//SORTOUT DD DUMMY                                             
//SYSIN DD *                                                   
 OPTION COPY,NULLOUT=RC4                                       
/*                                                             
// IF (RC=4) THEN                                               
// EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                                                   
*********COUNT NOT MATCH**********                             
/*                                                             
// DD DSN=*.S1.T1,DISP=(OLD,DELETE)                             
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                               
 OPTION COPY                               
/*                                         
// ELSE                                   
// IF (RC=0) THEN                         
// EXEC PGM=SORT                           
//SYSOUT DD SYSOUT=*                       
//SORTIN DD *                             
***********COUNT MATCH************         
/*                                         
// DD DSN=*.S1.T1,DISP=(OLD,DELETE)       
//SORTOUT DD SYSOUT=*                     
//SYSIN DD *                               
 OPTION COPY                               
/*                                         
// EXEC PGM=ICETOOL                       
//DFSMSG DD SYSOUT=*                       
//TOOLMSG DD SYSOUT=*                     
//FILE1 DD DSN=*.S1.FILE1,DISP=OLD                 
//FILE2 DD DSN=*.S1.FILE2,DISP=OLD                 
//T DD DSN=&&T,DISP=(MOD,PASS)                     
//MATCH DD SYSOUT=*                                 
//F1ONLY DD SYSOUT=*                               
//F2ONLY DD SYSOUT=*                               
//TOOLIN DD *                                       
 COPY FROM(FILE1) TO(T) USING(CTL1)                 
 COPY FROM(FILE2) TO(T) USING(CTL2)                 
 SPLICE FROM(T) TO(MATCH) ON(81,8,ZD) ON(5,6,CH) - 
 WITH(90,1) KEEPNODUPS USING(CTL3)                 
/*                                                 
//CTL1CNTL DD *                                     
 INREC OVERLAY=(81:SEQNUM,8,ZD,C'11')               
/*                                                 
//CTL2CNTL DD *                                     
 INREC OVERLAY=(81:SEQNUM,8,ZD,C'22')               
/*                                                 
//CTL3CNTL DD *                                               
 OUTFIL FNAMES=MATCH,INCLUDE=(89,2,CH,EQ,C'12'),OUTREC=(1,80) 
 OUTFIL FNAMES=F1ONLY,INCLUDE=(89,2,CH,EQ,C'11'),             
 OUTREC=(29C'*',C'RECORD NUMBER: ',81,8,28C'*',/,1,80)         
 OUTFIL FNAMES=F2ONLY,INCLUDE=(89,2,CH,EQ,C'22'),             
 OUTREC=(29C'*',C'RECORD NUMBER: ',81,8,28C'*',/,1,80)         
/*                                                             
// ENDIF                                                       
// ENDIF                                                       
//

Output:
Code:
***********COUNT MATCH************
COUNT OF RECORDS IN FILE1 00000010
COUNT OF RECORDS IN FILE2 00000010

Match
Code:
    AAAAAA
    BBBBBB
    EEEEEE
    FFFFFF
    111111
    444444

F1ONLY
Code:
*****************************RECORD NUMBER: 00000003****************************
    CCCCCC                                                                     
*****************************RECORD NUMBER: 00000007****************************
    222222                                                                     
*****************************RECORD NUMBER: 00000009****************************
    555555                                                                     
*****************************RECORD NUMBER: 00000010****************************
    999999

F2ONLY
Code:
*****************************RECORD NUMBER: 00000003****************************
    DDDDDD                                                                     
*****************************RECORD NUMBER: 00000007****************************
    333333                                                                     
*****************************RECORD NUMBER: 00000009****************************
    666666                                                                     
*****************************RECORD NUMBER: 00000010****************************
    777777
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top