Compare 2 files, excluding one fields from both.

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
ari2009
Member
Posts: 5
Joined: Wed Dec 16, 2009 11:50 pm

Compare 2 files, excluding one fields from both.

Post by ari2009 » Fri Dec 18, 2009 1:38 pm

Hi.
I need to perform a compare between two files, to make sure that other than the identified field, all other fields are same.

File1 : aaaabbbb2222ccc44444.......
File2 : aaaabbbb3333cccc44444.....

I have to compare all other fileds values of these files , excluding field with 2222 in F1 and 3333 in F2.

Both the files are FB and of samelength - 80
ARI

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Dec 18, 2009 8:27 pm

You need to do a better job of explaining what you want to do before anyone can help you.

What do you want to if (1) all of the fields are the same or (2) all of the fields are not the same.
excluding field with 2222 in F1 and 3333 in F2.
Do you mean you want to exclude the field in each input record at positions 9-12, or are 2222 and 3333 really significant in some way? How?

Do you only have one record in each file, or can there be more than one record in each file? If more, do you want to compare record 1 of file1 to record 1 of file2, record 2 of file1 to record 2 of file2, etc. Or do you want to do something else? If you can have more than one record in each file, show a better example of input and expected output.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

ari2009
Member
Posts: 5
Joined: Wed Dec 16, 2009 11:50 pm

Post by ari2009 » Fri Dec 18, 2009 9:15 pm

File1 :
rec1 - aaaabbbb2222cccc44444.......
rec2 - ccccxxxx1111dddd55555.......

File2 :
rec1 - aaaabbbb3333cccc44444.....
rec2 - ccccxxxx1111dddd55555.......

F1 and F2 can have any number of records. I want to exclude records from position 9 to 12 from both the files records and want to compare record 1 of F1 with record 1 of F2 and so on... all other fields excluding from position 9 to 12.
ARI

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sun Dec 20, 2009 6:51 am

Sigh. We're getting closer.

Again:
What do you want to if (1) all of the fields are the same or (2) all of the fields are not the same.
You say you want to compare the records, but you don't say what you want to do if the records are equal or not equal. So how can we give you a job to do what you haven't said you want to do?
show a better example of input and expected output.
Show an example of input and output where all of the fields (excluding 9-21) in two records are the same and where all of the fields (excluding 9-12) in two records are different. For example, if you had these input files, what would you expect for output and why?

File1 :
aaaabbbb2222cccc44444.......
ccccxxxx1111dddd55555.......
eeeeffff4444xxxxxxxxx.......
ffffffff0000xxxxxxxxx.......
hhhhhhhh1234qqqqqqqqq.......

File2 :
aaaabbbb3333cccc44444.......
ccccxxxx0000dddd55555.......
eeeeffff4444yyyyyyyyy.......
gggggggg0000xxxxxxxxx.......
hhhhhhhh4567qqqqqqqqq.......
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

ari2009
Member
Posts: 5
Joined: Wed Dec 16, 2009 11:50 pm

Post by ari2009 » Mon Dec 21, 2009 9:51 am

Hi,
further to the details provided, Please see the below example -

File1 :
aaaabbbb2222cccc4444.......
ccccxxxx1111dddd5555.......
eeeeffff4444xxxxyyyy.......
....

File2 :
aaaabbbb3333cccc4444.......
ccccxxxx0000dddd5555.......
eeeeffff44442222aaaa....

In file 2 record 3 , yyyy from file1 has been changed to aaaa.
The idea of my process to change values only for 4 bytes - 9 to 12 and keep other values same. To validate the process output -

The compare JCL should compare values of two files excludig those 4 bytes from both F1 & F2 as change is expected there. In case of any mismatch found in all other field values, as it is in present in Record 3; the record should be copied to the error file from File 1 and job should end with a return code to notify that to the user.

In addition to this - Can I start comparing from a perticular record - e.g - I want to skip first 10 reows of F1 and F2 while start comparinfg ? is it possible - please let me know. It will reduce a lot of my reformating effort before I start comparing files.
ARI

Alissa Margulies
Member
Posts: 25
Joined: Tue Apr 28, 2009 10:53 pm
Location: USA
Contact:

Post by Alissa Margulies » Thu Dec 31, 2009 12:27 am

Here is a SyncSort for z/OS JOIN application that will produce the requested output:

Code: Select all

//SORT1  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                  
//SORTJNF1 DD *                            
AAAABBBB2222CCCC4444...                       
CCCCXXXX1111DDDD5555...                       
EEEEFFFF4444XXXXYYYY...                       
//SORTJNF2 DD *                            
AAAABBBB3333CCCC4444...                       
CCCCXXXX0000DDDD5555...                       
EEEEFFFF44442222AAAA...                       
//SORTOUT  DD DSN=OUTPUT.FILE
//SYSIN    DD *                               
   JOINKEYS FILES=F1,FIELDS=(1,8,A,13,68,A)
   JOINKEYS FILES=F2,FIELDS=(1,8,A,13,68,A)
   JOIN UNPAIRED,F1,ONLY                   
   REFORMAT FIELDS=(F1:1,80)               
   SORT FIELDS=COPY                        
/*                                         
If there is always a 1:1 correlation between the two files, and the data is pre-sequenced, then you can add SORTED to each of the JOINKEYS statements as follows:

Code: Select all

   JOINKEYS FILES=F1,FIELDS=(1,8,A,13,68,A),SORTED
   JOINKEYS FILES=F2,FIELDS=(1,8,A,13,68,A),SORTED
Based on this data, then following record will be in the output file:

Code: Select all

EEEEFFFF4444XXXXYYYY...
I will get back to you regarding setting a non-zero return code when records are present in the output file.
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Dec 31, 2009 5:31 am

If you have the Nov, 2009 DFSORT PTF, you can use JOINKEYS with DFSORT as well. In addition, you can skip the first 10 records of each input file by adding:

Code: Select all

//JNF1CNTL DD *
  OPTION SKIPREC=10
//JNF2CNTL DD *
  OPTION SKIPREC=10
/*
For more information on the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss? ... g3T7000174

It would help if you would tell us which Sort product you're actually using (DFSORT, Syncsort, CA-Sort).
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others