Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Compare two files on the basis of RECORD COUNT.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ANKUL KHANDELWAL

New User


Joined: 15 Feb 2007
Posts: 8
Location: pune

PostPosted: Mon Jun 06, 2011 6:10 pm    Post subject: Compare two files on the basis of RECORD COUNT.
Reply with quote

Hi icon_smile.gif
I have two input files in jcl ....(Say Todays file and yesterday's file).
Can i use SORT to find if todays file is having RECORD Count greater than yertaerday ? aslo need to find the difference between the two files ....
Back to top
View user's profile Send private message

gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Mon Jun 06, 2011 6:19 pm    Post subject:
Reply with quote

You can use COUNT to count the number of records in each dataset and write the count to the output datasets say count1 and count2. Then compare both the output datasets count1 and count2.

What kind of difference you want to check in both the files?
Back to top
View user's profile Send private message
ANKUL KHANDELWAL

New User


Joined: 15 Feb 2007
Posts: 8
Location: pune

PostPosted: Mon Jun 06, 2011 6:32 pm    Post subject: Compare two files on the basis of RECORD COUNT.
Reply with quote

Agreed. I have record counts in count1 and Count2 .
Now can i use SORT to find which file is having more number of records..and print the actual difference in record count in another output file ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Jun 06, 2011 6:41 pm    Post subject: Reply to: Compare two files on the basis of RECORD COUNT.
Reply with quote

Don't you have record counts from all the programs which created/read the dataset?

What does "have two input files in JCL" mean? Do you mean DD *? Datasets are normally in the catalogue, don't know how to put them in JCL.

If they are transactions, you are going to get huge differences (probably every single record).

If it is a "static" file, you should have some output/enquiry showing you the add/delete/updates.

If it is just a once-off, can you browse the files, go to the end, add for the number of lines on the screen, write on a piece of paper, calculate?

Or is this another "backfill" exercise for not having done the job properly in the first place?
Back to top
View user's profile Send private message
ANKUL KHANDELWAL

New User


Joined: 15 Feb 2007
Posts: 8
Location: pune

PostPosted: Mon Jun 06, 2011 6:56 pm    Post subject: Compare two files on the basis of RECORD COUNT.
Reply with quote

Thanks Bill !!
Just to clarify ....
Files are not Static / This is not once-off operation / nor it is backfill exercise.
let me put it simple
I have two files ..
1. XDMC.PDFS.TEST1 - (Created by batch job yesterday..)
2. XDMC.PDFS.TEST2 - (Created by batch job Today..)

Question
1. I want to find which file is having more number of records and by how much(Difference between the record counts of two files) ?
2. Can i use Subtract operation via SORT ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Jun 06, 2011 7:11 pm    Post subject: Reply to: Compare two files on the basis of RECORD COUNT.
Reply with quote

Still losing it.

Million ways to count records in sort. Just do any sort without dropping or inserting any records, and it tells you how many records it processed.

Take pencil, write down figure. Same thing with the second dataset. Subtract. As long as you remember which figure was which, then you have an answer.

If you still want the different data between the files, there is always JOINKEYS. Play around with that. I even suspect it will give you seperate counts in the output listing for the two files.

If you want to count and subtract with sort, then yes, probably. There have been a few examples recently. Search the forum for "trailer" and you'll probably get some useful examples.

Or if you have a file comparison product, you could try that, but then you don't get to subtract in sort (and the file comparison probably won't do the subtract, you'd have to actually look at the listing to get the answer).
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Jun 06, 2011 7:45 pm    Post subject:
Reply with quote

ANKUL KHANDELWAL,
See if below works for you.

I have assumed LRECL of 80 and FB for both the input files. The job below writes a trailer kind record indicating if previous day or current has more number of records and their respective difference in counts. If they have same number of records then it also indicates the same.

If this is not what you want, please provide sample input and expected output.

To answer your question, yes DFSort can use Subtract operation via SORT

Code:
//STEP0001 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//CURRDAY  DD *                                                         
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//PREVDAY  DD *                                                         
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY                             
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY                             
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY                             
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  JOINKEYS F1=CURRDAY,FIELDS=(81,1,A)                                   
  JOINKEYS F2=PREVDAY,FIELDS=(81,1,A)                                   
  REFORMAT FIELDS=(F1:82,08,F2:82,08)                                   
  INREC IFTHEN=(WHEN=INIT,                                             
                OVERLAY=(21:1,8,ZD,SUB,09,08,ZD,TO=ZD,LENGTH=08)),     
        IFTHEN=(WHEN=(21,8,ZD,GT,0),                                   
                BUILD=(C'CURRENT  DAY FILE HAS ',21,8,ZD,M11,LENGTH=08,
                       C' MORE RECORDS THAN PREVIOUS DAY FILE')),       
        IFTHEN=(WHEN=(21,8,ZD,LT,0),                                   
                BUILD=(C'PREVIOUS DAY FILE HAS ',21,8,ZD,M11,LENGTH=08,
                       C' MORE RECORDS THAN CURRENT DAY  FILE')),       
        IFTHEN=(WHEN=(21,8,ZD,EQ,0),                                   
                BUILD=(C'CURRENT DAY AND PREVIOUS DAY FILES HAVE THE ',
                       C'NUMBER OF RECORDS - ',01,8,ZD,M11,LENGTH=08)) 
  SORT FIELDS=COPY                                                     
/*                                                                     
//JNF1CNTL DD *                                                         
 INREC OVERLAY=(81:C'A',7C'0',C'1')                                     
 SUM FIELDS=(82,8,ZD)                                                   
/*                                                                     
//JNF2CNTL DD *                                                         
 INREC OVERLAY=(81:C'A',7C'0',C'1')                                     
 SUM FIELDS=(82,8,ZD)                                                   
/*                                                                     

OUTPUT
Code:
CURRENT  DAY FILE HAS 00000002 MORE RECORDS THAN PREVIOUS DAY FILE

Thanks,
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Jun 06, 2011 8:34 pm    Post subject:
Reply with quote

I noticed OPTION COPY and SORT FIELDS=COPY in the job I posted above and basically I don't have edit authority for my post.

Please delete the line with OPTION COPY.
Done

Thanks,
Back to top
View user's profile Send private message
ANKUL KHANDELWAL

New User


Joined: 15 Feb 2007
Posts: 8
Location: pune

PostPosted: Wed Jun 08, 2011 1:01 am    Post subject: Compare two files on the basis of RECORD COUNT.
Reply with quote

Thanks a lot !!! This similar to what i needed.
two more questions
1. Based on the output i get ...say
IF previous day file had more records than only need to execute next steps...Is posssible to do via JCL ?.....(I have seen return code being passed by COBOL and than evaluating it JCL but i dont want to it via COBOL)
2. Can we also perform division and multiplication operations via DFSORT? please suggest a location where i can find some documentation on the use Arithmetic operation via sort....
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jun 08, 2011 1:47 am    Post subject:
Reply with quote

2. Yes. For more information, see:

https://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000089

and

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG50/2.4.10?DT=20100628091856

In general, if you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Jun 08, 2011 2:40 am    Post subject:
Reply with quote

ANKUL KHANDELWAL,
Quote:
IF previous day file had more records than only need to execute next steps...Is posssible to do via JCL ?.....(I have seen return code being passed by COBOL and than evaluating it JCL but i dont want to it via COBOL)
If I understand this correctly, you want to set different return codes based on condition(RC=0 if matched,4 if previous day count is higher and 8 if current day is higher). As far as I know,DFSort can only set one of the two return code(i.e. 0 if both counts are same or 4/8/16 if they are not same).

See if below works... This sets RC16 if counts don't match.
Code:
  JOINKEYS F1=CURRDAY,FIELDS=(81,1,A)                             
  JOINKEYS F2=PREVDAY,FIELDS=(81,1,A)                             
  REFORMAT FIELDS=(F1:82,08,F2:82,08)                             
  SORT FIELDS=COPY                                                 
 OUTREC IFTHEN=(WHEN=INIT,                                         
                OVERLAY=(21:1,8,ZD,SUB,09,08,ZD,TO=ZD,LENGTH=08)) 
 OUTFIL NULLOFL=RC16,INCLUDE=(21,8,ZD,EQ,0)                       

Quote:
Can we also perform division and multiplication operations via DFSORT? please suggest a location where i can find some documentation on the use Arithmetic operation via sort....
Start from here

Thanks,
Back to top
View user's profile Send private message
ANKUL KHANDELWAL

New User


Joined: 15 Feb 2007
Posts: 8
Location: pune

PostPosted: Wed Jun 08, 2011 5:28 pm    Post subject: Compare two files on the basis of RECORD COUNT.
Reply with quote

Thanks I am going through the documents and trying to learn more on how to use Arithmetic operation via sort...

I want to do this

Input files LRECL = 133 and FBA

If previous day file is having 4% more records than current days file than
1. Copy file XFSD.RAFA.TA6AVA to XFSD.RAFA.TA6AVC (these are the files we are comparing)
2. Send out email (this is not problem...)

i have implemented above using cobol...but now need to implement same via JCL ...please suggest
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 08, 2011 8:01 pm    Post subject:
Reply with quote

Hello,

Quote:
i have implemented above using cobol...but now need to implement same via JCL ...please suggest
Suggest you tell whoever wants this done "via JCL" that it can't be done. You might execute the sort or some other utility, but JCL cannot do this.

If this is already running as needed, why waste time converting to some other syntax?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Jun 08, 2011 8:24 pm    Post subject:
Reply with quote

ANKUL KHANDELWAL,
I wish you would have given all the requirements earlier in the first post itself...See if below jcl helps... I have kept results of intermediate arithmetic operations for you understand the logic.

This job sets Return code of 16 if previous day file is having 4% more records than current day and then later in the subsequent steps, you could use COND of JCL to make decision on emailing...

Code:
//STEP0001 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//CURRDAY  DD *                                           
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               
//PREVDAY  DD *                                           
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY               
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  JOINKEYS F1=CURRDAY,FIELDS=(1,1,A)                     
  JOINKEYS F2=PREVDAY,FIELDS=(1,1,A)                     
  REFORMAT FIELDS=(F1:02,08,F2:02,08)                     
  SORT FIELDS=COPY                                       
  OUTREC IFTHEN=(WHEN=INIT,                               
  OVERLAY=(01:01,16,04X,                                 
           21:(01,08,ZD,MUL,+100),TO=ZD,LENGTH=10,       
           31:(09,08,ZD,MUL,+100),TO=ZD,LENGTH=10,       
           41:(01,08,ZD,MUL,+004),TO=ZD,LENGTH=10,       
           51:21,10,ZD,ADD,41,10,ZD,TO=ZD,LENGTH=10))     
  OUTFIL INCLUDE=(51,10,ZD,GT,31,10,ZD),NULLOFL=RC16     
/*                                                       
/*                                     
//JNF1CNTL DD *                       
 INREC BUILD=(C'A',7C'0',C'1')         
 SUM FIELDS=(2,8,ZD)                   
/*                                     
//JNF2CNTL DD *                       
 INREC BUILD=(C'A',7C'0',C'1')         
 SUM FIELDS=(2,8,ZD)                   
/*                                     
//EMAIL001 EXEC PGM=XXXX,             
//             COND=(0,EQ,STEP0001)     
...                                   
...                                   


Thanks,
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Jun 08, 2011 8:28 pm    Post subject:
Reply with quote

dick scherrer wrote:
If this is already running as needed, why waste time converting to some other syntax?

I suspect that the answer is revealed by this:
ANKUL KHANDELWAL wrote:
Input files LRECL = 133 and FBA
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 08, 2011 10:51 pm    Post subject: Re: Compare two files on the basis of RECORD COUNT.
Reply with quote

ANKUL KHANDELWAL wrote:

If previous day file is having 4% more records than current days file than


4% results in tiny fraction of records. Any thing below 25 results in a fraction. What do you in that case? Do you round upwards or downwards?

Sqlcode1,

Run your job with empty files (both prevday and currday files being empty) and check if you are getting the right results.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Jun 09, 2011 1:57 am    Post subject:
Reply with quote

Quote:
Run your job with empty files (both prevday and currday files being empty) and check if you are getting the right results.

It abends. That's a curve ball or rather reverse swing icon_smile.gif
Any suggestions to do that in the same pass?

Thanks,
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jun 09, 2011 4:07 am    Post subject: Reply to: Compare two files on the basis of RECORD COUNT.
Reply with quote

sqlcode1 wrote:
It abends. That's a curve ball or rather reverse swing icon_smile.gif
Any suggestions to do that in the same pass?


Sqlcode1,

It abends? Unless your shop has ABEND in effect (e.g. from ERET=ABEND or DEBUG ABEND) I don't see a reason as to why you have an abend.

Checking for empty files is neither a curve ball or reverse swing. It is the first thing you need to consider when matching the files.

ANKUL KHANDELWAL,

The following JCL will give you the desired results. The following return codes are set

Code:

RC = 00 = Prevday file count >= currday_count + 4% of currday_count
RC = 00 = Currday file is empty and prevday file has atleast 1 record

RC = 04 = Prevday file count <  currday_count + 4% of currday_count
RC = 04 = prevday file is empty and currday file has atleast 1 record

RC = 16 = both Prevday and Currday files are empty




Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//CURRDAY  DD *                                                     
XXXXXXXXXXXXXX                                                       
//PREVDAY  DD *                                                     
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY                           
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY                           
//SORTOUT  DD SYSOUT=*                                               
//SETCODE  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  JOINKEYS F1=CURRDAY,FIELDS=(1,1,A)                                 
  JOINKEYS F2=PREVDAY,FIELDS=(1,1,A)                                 
  REFORMAT FIELDS=(F1:02,08,F2:02,08,?),FILL=X'00'                   
  JOIN UNPAIRED                                                     
  OPTION COPY,NULLOUT=RC16                                           
  INCLUDE COND=(17,1,SS,EQ,C'B,1,2')                                 
  OUTFIL FNAMES=SETCODE,NULLOFL=RC4,                                 
  INCLUDE=(17,1,SS,EQ,C'B,2',AND,9,8,PD,GE,1,8,PD)                   
//*                                                                 
//JNF1CNTL DD *                                                     
  INREC BUILD=(C'A',X'000000000000104C')                             
  SUM FIELDS=(2,8,PD)                                               
/*                                                                   
//JNF2CNTL DD *                                                     
  INREC BUILD=(C'A',X'000000000000100C')                             
  SUM FIELDS=(2,8,PD)                                               
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us