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

Compare two files on the basis of RECORD COUNT.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
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
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 06, 2011 6:41 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 06, 2011 7:11 pm
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: 577
Location: USA

PostPosted: Mon Jun 06, 2011 7:45 pm
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: 577
Location: USA

PostPosted: Mon Jun 06, 2011 8:34 pm
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
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 Developer


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

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

2. Yes. For more information, see:

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

and

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:

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: 577
Location: USA

PostPosted: Wed Jun 08, 2011 2:40 am
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
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

Moderator Emeritus


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

PostPosted: Wed Jun 08, 2011 8:01 pm
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: 577
Location: USA

PostPosted: Wed Jun 08, 2011 8:24 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed Jun 08, 2011 8:28 pm
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
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: 577
Location: USA

PostPosted: Thu Jun 09, 2011 1:57 am
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
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
Tripti Jaiswal

New User


Joined: 24 Jan 2020
Posts: 1
Location: India

PostPosted: Fri Jan 24, 2020 10:23 am
Reply with quote

Deleted -
1) load of rubbish
2) Topic is 9 years old
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. 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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top