Compare the total number of records in 2 files.

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
User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Compare the total number of records in 2 files.

Post by anilanju » Wed May 13, 2009 7:07 pm

Hi

I have 2 files
File a
File b

In both the files the number of records keep on changing.
Len rec=133
Format =FB.

In the trailer record we get the total number of transaction in the file.
I need to comapre the the trailer record to find if number of transaction is same in both files or not.

Regards
Anju

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

Post by Frank Yaeger » Wed May 13, 2009 7:37 pm

I need to comapre the the trailer record to find if number of transaction is same in both files or not.
What do you want to do if they are the same? What do you want to do if they are different?

Is the trailer record the only record in the file? If not, is there something in the trailer record that identifies it? What is the starting position, length and format of the number of transactions in the trailer record? Please show an example of what the trailer record looks like.
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Wed May 13, 2009 8:17 pm

HI

No there are many records in the file.

Trailers records are same in format but the number of transaction keeps on changing eveyr day.

I need to compare the number of records in the file.and that is written in the trailer record.

Is there any other way to find number of records in two files and comapre them?

This is the format of the trailer record. and number of transactions is
000006385

ANU0000063852007-12-12

So i need to compare 000006385 these position in two files.

But i would ask for other option also, if there are no trailer records thn how to find the total records and compare them.

Regards
Anju

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

Post by Frank Yaeger » Wed May 13, 2009 8:46 pm

You didn't answer all of my questions.

Sorry, but you haven't really given clear enough information for me to help you.
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Wed May 13, 2009 8:53 pm

hi

if the number is same in trailer records, then we need to perform further step and if they are diffrent they we ll not proceed further.

the format of trailer record is ANU0000063852007-12-12 , starting from position 1.

where 000006385 is the number of reocrds in tht file.and 2007-12-12 is the date.


If this number 000006385 is same in both the files then we can proceed furthet if not then we cant.

But this number is not fixed it keeps on changin daily.

Hope this help.
Regards Anju

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

Post by Frank Yaeger » Wed May 13, 2009 9:50 pm

if the number is same in trailer records, then we need to perform further step and if they are diffrent they we ll not proceed further.


Does that mean you want a RC=0 if the counts are equal or a RC>0 if the counts are not equal?

Again,is there something in the trailer record that identifies it? Like 'ANU' in positions 1-3 or something else? Or is the trailer record just the last record in the file with no other identifier?
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Thu May 14, 2009 1:03 pm

Hi

The requirement has changed a bit.
One file has a trailer record another one doesnot have.

I just need to compare the number of records in both the files.

How can i do that.

Trailer record :ANU0000063852007-12-12
here from position 4 to 12 is the number ofr ecords in the file.
but porblem is that only one file has it, second file does not have a trailer record.

Yes trailer record is the last record.

Regards
Anju

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 May 14, 2009 11:17 pm

Here's a DFSORT/ICETOOL job that will give you RC=0 if the number of records in the two files is the same, or RC=16 if the number of records in the two files is different. I assumed input file1 has a trailer (which you don't want to count in the number of records) and input file2 does not have a trailer. I didn't actually use the count in the trailer of input file1 since it's irrelevant. If you prefer RC=4 to RC=16, you can use NULLOFL=RC4 instead of NULLOFL=RC16.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=... input file1 (has trailer)
//IN2 DD DSN=... input file1 (no trailer)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DUMMY
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
COPY FROM(T1) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
   TRAILER1=(COUNT-1=(M11,LENGTH=9))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
   TRAILER1=(11:COUNT=(M11,LENGTH=9))
/*
//CTL3CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(1:1,9))
  OUTFIL STARTREC=2,INCLUDE=(1,9,ZD,EQ,11,9,ZD),NULLOFL=RC16
/*
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