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 

How to find record count that belongs to particular key

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


Joined: 15 Sep 2006
Posts: 64
Topics: 22

PostPosted: Mon Feb 26, 2007 7:05 am    Post subject: How to find record count that belongs to particular key Reply with quote

Hi All,
I have a input file with record lenght of 250. (10,11) bytes are key fields. This is not unique key. I have a requirement, I want to count the key field and if same key avail in the input file more than 400 times than i have to drop first 200 records with that key. Is there any way to do this in SORT.
Please help me.

Input file
xxxxxxxx12345678901....
yyyyyyyy12345678901....
zzzzzzzzz12345678901....
.
.
.

12345678901 - Key field if this exceeds 400 times than i have to drop first 200 records for this key


Thanks in advance
Kavi
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 26, 2007 8:34 am    Post subject: Reply with quote

kavi,

What do you want to do if the key occurance is less than 200 ? Do you want to copy them to output or drop them ?

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


Joined: 15 Sep 2006
Posts: 64
Topics: 22

PostPosted: Tue Feb 27, 2007 1:37 am    Post subject: Reply with quote

Kolusu,
Thanks for your reply
Yes if the key occurance is less than 400 than i have to copy that into output file.
If its greater than 400 I have to drop first 200 occurances and remaining will be copied into output file.


Thanks in advance
Kavi
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: Tue Feb 27, 2007 9:04 am    Post subject: Reply with quote

kavi,

Try this DFSORT/ICETOOL jcl which does give you the desired results.

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD DSN=your input file,
//            DISP=SHR                                         
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  SORT FROM(IN) USING(CTL1)                             
  SPLICE FROM(T1) TO(T2) ON(10,11,CH) WITH(01,266) -     
         WITHALL KEEPBASE USING(CTL2)                   
  SORT FROM(T2) USING(CTL3)                             
                                                         
//CTL1CNTL DD *                                         
  INREC IFTHEN=(WHEN=INIT,                               
       OVERLAY=(251:SEQNUM,8,ZD))                       
                                                         
  SORT FIELDS=(10,11,CH,A)                               
  OUTREC IFTHEN=(WHEN=INIT,                             
        OVERLAY=(259:SEQNUM,8,ZD,RESTART=(10,11),       
                 267:C'N'),HIT=NEXT),                   
         IFTHEN=(WHEN=(259,8,ZD,GT,400),                   
        OVERLAY=(267:C'Y'))                             
                                                         
  OUTFIL FNAMES=T1                                       
/*
//CTL2CNTL DD *                                             
  SORT FIELDS=(010,11,CH,A,                                 
               267,01,CH,D)                                 
                                                           
  OUTFIL FNAMES=T2,OMIT=(259,8,ZD,LE,200,AND,267,1,CH,EQ,C'Y')
/*                                                         
//CTL3CNTL DD *                                             
  SORT FIELDS=(251,08,CH,A)                                 
  OUTFIL FNAMES=OUT,OUTREC=(01,250)     
/*


Hope this helps...

Cheers

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


Joined: 15 Sep 2006
Posts: 64
Topics: 22

PostPosted: Wed Feb 28, 2007 12:14 am    Post subject: Reply with quote

Kolusu,
Thanks it helps me lot. Is there any way to do this is in SYNCSORT



Thanks in advance
Kavi
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 Feb 28, 2007 9:37 am    Post subject: Reply with quote

kavi wrote:
Kolusu,
Thanks it helps me lot. Is there any way to do this is in SYNCSORT


Thanks in advance
Kavi


Kavi,

If you have the latest version of Syncsort , the above job works

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


Joined: 15 Sep 2006
Posts: 64
Topics: 22

PostPosted: Thu Mar 01, 2007 7:15 am    Post subject: Reply with quote

Kolusu,
Thanks for your help, It works fine

Thanks
Kavi
Back to top
View user's profile Send private message
Arunprasad.K
Beginner


Joined: 18 Jan 2006
Posts: 18
Topics: 5
Location: Chennai, India

PostPosted: Fri Apr 20, 2007 1:26 am    Post subject: Reply with quote

What I have to do if I want to copy only the first 100 occurance? If there is less than 100 occurance then I have to copy all the records.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Apr 20, 2007 4:55 am    Post subject: Reply with quote

Quote:

IFTHEN=(WHEN=(259,8,ZD,GT,400),


Arunprasad.K,

Find this statement in the solution posted by me and apply your condition.

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


Joined: 12 Dec 2006
Posts: 15
Topics: 3

PostPosted: Fri Apr 20, 2007 12:09 pm    Post subject: Reply with quote

Hi kolusu

errr, i have a question.
notes this statement,"WHEN=(259,8,ZD,GT,400), OVERLAY=(267:C'Y')"
it may means , only when 259,8,ZD,GT,400 , the 267,1,ch,equals y
but the following outfil condition says
"OMIT=(259,8,ZD,LE,200,AND,267,1,CH,EQ,C'Y')"
there seems a conflict between them,
or did i misunderstand?
i beg for your reply.
thanks in advance.

Ben
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: Fri Apr 20, 2007 12:33 pm    Post subject: Reply with quote

waitling,

The original requirement was

kavi wrote:
I want to count the key field and if same key available in the input file more than 400 times than i have to drop first 200 records with that key.


Quote:
WHEN=(259,8,ZD,GT,400), OVERLAY=(267:C'Y')"


So the first WHEN condition is checking if the count of each key is greater than 400. If it is then it sets up a flag of 'Y'.

Now I am splicing this flag 'y' to all the records, as the requirement is to drop the first 200 records if the key is repeated more than 400 times.

That is where the second condition comes into picture

Quote:
OMIT=(259,8,ZD,LE,200,AND,267,1,CH,EQ,C'Y')


Hope this helps...

Cheers

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


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

PostPosted: Fri Apr 20, 2007 12:59 pm    Post subject: Reply with quote

waitling,

For a better understanding, consider the following input

Code:

A -REC # 01 
A -REC # 02 
A -REC # 03 
A -REC # 04 
A -REC # 05 
A -REC # 06 
B -REC # 01 
B -REC # 02 
B -REC # 03 


Now for each key(the first byte) if the key occurs more than 5 times I have to drop the first 2 records of key. So I am expecting the folloiwng output

Code:

A -REC # 03 
A -REC # 04 
A -REC # 05 
A -REC # 06 
B -REC # 01 
B -REC # 02 
B -REC # 03 


If you look at the above output, I have dropped rec # 1 and rec # 2 for the key 'A'. Since the key 'B' has only 3 records and 3 is not greater than our threshold limit of key we retain all the keys.

Now run the following job

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                         
A -REC # 01                                             
A -REC # 02                                             
A -REC # 03                                             
A -REC # 04                                             
A -REC # 05                                             
A -REC # 06                                             
B -REC # 01                                             
B -REC # 02                                             
B -REC # 03                                             
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//P1       DD SYSOUT=*                                   
//OUT1     DD SYSOUT=*                                   
//OUT2     DD SYSOUT=*                                   
//TOOLIN   DD *                                             
  SORT FROM(IN) USING(CTL1)                                 
  SPLICE FROM(T1) TO(OUT1) ON(01,1,CH) WITH(01,49) -       
         WITHALL KEEPBASE USING(CTL2)                       
//CTL1CNTL DD *                                             
  SORT FIELDS=(1,1,CH,A)                                   
  OUTREC IFTHEN=(WHEN=INIT,                                 
        OVERLAY=(41:SEQNUM,8,ZD,RESTART=(1,1),             
                 50:C'N'),HIT=NEXT),                       
         IFTHEN=(WHEN=(41,8,ZD,GT,5),                       
        OVERLAY=(50:C'Y'))                                 
                                                           
  OUTFIL FNAMES=(T1,P1)                                     
//CTL2CNTL DD *                                             
  SORT FIELDS=(001,01,CH,A,                                 
               050,01,CH,D)                                 
  OUTFIL FNAMES=OUT1                                       
  OUTFIL FNAMES=OUT2,OMIT=(41,8,ZD,LE,2,AND,50,1,CH,EQ,C'Y')
/*                                                         


Now check the output from ddnames P1(this will have the results from first pass)

OUT1 will have all the records without the omit condition and out2 will have the results after the omit condition is applied.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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