MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compare last month file with current month using sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
rkarthik22
Beginner


Joined: 27 Sep 2008
Posts: 24
Topics: 9

PostPosted: Wed Jan 20, 2010 10:22 am    Post subject: Compare last month file with current month using sort Reply with quote

Hi Experts,

We have two files, Last month Account file (LRECL: 1160) and this month , current, month Account file (LRECL: 1160)

Both the files doesn't have any headers or trailers.

We have to compare the last month counts (no of records present in the file) with the current month count in the file

If the count difference is more than 5% , then we have to send a mail to the team,

Is this possible in Sort or any Utilities.

Please help me..
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 20, 2010 1:01 pm    Post subject: Reply with quote

rkarthik22,

The following DFSORT JCL will set an RC=4 if the counts from the 2 files vary by 5%. If the return code from the step is 4 send the email in next step.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//LASTMON  DD DSN=your LAST month file,DISP=SHR             
//CURRMON  DD DSN=your CURR month file,DISP=SHR             
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                         
  SORT FIELDS=COPY
  JOINKEYS F1=LASTMON,FIELDS=(9,1,A)                       
  JOINKEYS F2=CURRMON,FIELDS=(9,1,A)                       
  REFORMAT FIELDS=(F1:1,8,F2:1,8)                           
  OUTREC OVERLAY=(20:1,8,ZD,SUB,9,8,ZD,M11,LENGTH=8,       
                  30:(1,8,ZD,MUL,+5),DIV,+100,M11,LENGTH=8)
  OUTFIL NULLOFL=RC4,INCLUDE=(20,8,ZD,EQ,30,8,ZD)           
//*
//JNF1CNTL DD *                                             
  INREC FIELDS=(7C'0',C'1',X)                               
  SUM FIELDS=(1,8,ZD)                                       
//*
//JNF2CNTL DD *                                             
  INREC FIELDS=(7C'0',C'1',X)                               
  SUM FIELDS=(1,8,ZD)                                       
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rkarthik22
Beginner


Joined: 27 Sep 2008
Posts: 24
Topics: 9

PostPosted: Thu Jan 21, 2010 10:10 am    Post subject: Re: Reply with quote

Kolusu,

Thanks for your SORT Card..

If you dont mind can you please tell what the below two lines implies..please

Code:

JOINKEYS F1=LASTMON,FIELDS=(9,1,A)                       
JOINKEYS F2=CURRMON,FIELDS=(9,1,A)


My last month account file has got 60 million records and my current month file has got 62 million records.

Both the files having only detail records, no headers or trailers

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 21, 2010 12:01 pm    Post subject: Reply with quote

rkarthik22,

I created a 9 byte files for both current and last month files using JNF1CNTL and JNF2CNTL. The first 8 bytes will have a numeric 1 and 9th byte is a space. The space is used as a key for sum sorting and matching.

F1=lastmon is used to indicate that the JOINKEYS statement applies to the F1 input file.

F2=currmon is used to indicate that the JOINKEYS statement applies to the F2 input file.

For complete details on JOINKEYS and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Sun Feb 21, 2010 11:27 am    Post subject: Reply with quote

Here is another flavour of the same logic. Of course I had to use Kolusu's percentage logic.

Here we first create 2 intermediate count files for PREV and CURR month files and save them in T1 and T2 respectively. I am also creating 1 byte key C'1' in both the files to be used in JOINKEY.

Finally using JOINKEYS we join both the files and perform % logic.

The only difference between 2 logic is Kolusu's version is using INREC and SUM FIELDS to create COUNT where as this version is using REMOVECC...COUNT.


Code:
//SORT01   EXEC PGM=ICETOOL                                             
//LASTMON  DD DISP=SHR,DSN=YOUR LAST MONTH FILE                         
//CURRMON  DD DISP=SHR,DSN=YOUR CURR MONTH FILE                         
//T1       DD  DSN=&&T1,                                               
//             DISP=(MOD,PASS),                                         
//             SPACE=(CYL,(10,05))                                     
//T2       DD  DSN=&&T2,                                               
//             DISP=(MOD,PASS),                                         
//             SPACE=(CYL,(10,05))                                     
//OUT      DD  SYSOUT=*                                                 
//TOOLIN   DD  *                                                       
 COPY   FROM(LASTMON) TO(T1)  USING(CTL1)                               
 COPY   FROM(CURRMON) TO(T2)  USING(CTL1)                               
 COPY JKFROM TO(OUT) USING(CTL2)                                       
/*                                                                     
//CTL1CNTL DD  *                                                       
 OPTION COPY                                                           
 OUTFIL NODETAIL,REMOVECC,                                             
 TRAILER1=('1',COUNT=(M11,LENGTH=08))                                   
/*                                                                     
//CTL2CNTL DD  *                                                       
 JOINKEYS F1=T1,FIELDS=(1,1,A)                                         
 JOINKEYS F2=T2,FIELDS=(1,1,A)                                         
 REFORMAT FIELDS=(F1:2,8,F2:2,8)                                       
   OUTREC OVERLAY=(20:1,8,ZD,SUB,9,8,ZD,M11,LENGTH=8,                   
                   30:(1,8,ZD,MUL,+5),DIV,+100,M11,LENGTH=8)           
   OUTFIL NULLOFL=RC4,INCLUDE=(20,8,ZD,EQ,30,8,ZD)                     
/*                                                                     
//SORTDIAG DD  DUMMY                                                   
//SYSOUT    DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*                                                 
//TOOLMSG  DD  SYSOUT=*                                                 
//DFSMSG   DD  SYSOUT=*                                                 



Thanks,
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Feb 22, 2010 11:11 am    Post subject: Reply with quote

Sqlcode,

*Sigh* I know you are eager to test out the New PTF functions but please do NOT post inefficient solutions involving multiple passes of data.

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Mon Feb 22, 2010 11:26 am    Post subject: Reply with quote

Kolusu,

Figured that out when I did volume test with the test file today morning.
During the weekend I didn't get time to do volume testing and compare run times and/or cpu consumption.

Lesson learnt. In the future, will try to test efficiency before posting.


Thanks,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group