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 

Get Counts based on flags and total count using DFSORT

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


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Wed Sep 16, 2009 11:38 pm    Post subject: Get Counts based on flags and total count using DFSORT Reply with quote

I have one input file with following record structure:

Headquarter X(10)
Company X(10)
Emp no 9(10)
Feedback X(01)

Sample Input file:

Code:
NEWYORK     SONY      10001     E
NEWYORK     SONY       256         P
NEWYORK     SONY       1235      E
NEWYORK     SONY       586         P
NEWYORK     SONY       854         W
NEWYORK     REDIFF    11         P
NEWYORK     REDIFF    12         P
NEWYORK     REDIFF    13         P
NEWYORK     REDIFF    14         P
ALABAMA     YAHOO       111         E
ALABAMA     YAHOO       116         P
ALABAMA     YAHOO       286         W
ALABAMA     YAHOO       845         E
ALABAMA     YAHOO       246         P


I need following output from my job:

Output record structure is:

Headquarter X(10)
Company X(10)
Total no of Employees under one Company 9(02)
No Empls with 'E' feedback under one Company 9(02)
No Empls with 'P' feedback under one Company 9(02)
No Empls with 'W' feedback under one Company 9(02)

Sample Output file:

Code:
NEWYORK   SONY   5   2   2   1
NEWYORK   REDIFF   4   0   0   4
ALABAMA   YAHOO   5   2   2   1


Please help me in achieving in above solution through DFSORT or anyother utility
_________________
Thanks
Madhu Sudhan
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 Sep 17, 2009 2:34 pm    Post subject: Reply with quote

psmadhusudhan,

The following DFSORT JCL will give you the desired results. I assumed that your input is already sorted on the key (Headquarter and Company) . If not change the SORT FIELDS=COPY to SORT FIELDS=(1,20,CH,A)

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
----+----1----+----2----+----3----+----4----+----5----+----
NEWYORK     SONY         10001E                           
NEWYORK     SONY           256P                           
NEWYORK     SONY          1235E                           
NEWYORK     SONY           586P                           
NEWYORK     SONY           854W                           
NEWYORK     REDIFF          11P                           
NEWYORK     REDIFF          12P                           
NEWYORK     REDIFF          13P                           
NEWYORK     REDIFF          14P                           
ALABAMA     YAHOO          111E                           
ALABAMA     YAHOO          116P                           
ALABAMA     YAHOO          286W                           
ALABAMA     YAHOO          845E                           
ALABAMA     YAHOO          246P                           
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,20,31,1,C'1000')),     
  IFTHEN=(WHEN=(21,1,CH,EQ,C'E'),OVERLAY=(23:C'1')),       
  IFTHEN=(WHEN=(21,1,CH,EQ,C'P'),OVERLAY=(24:C'1')),       
  IFTHEN=(WHEN=(21,1,CH,EQ,C'W'),OVERLAY=(25:C'1'))       
                                                           
  OUTFIL NODETAIL,REMOVECC,BUILD=(28X),                   
  SECTIONS=(1,20,                                         
  TRAILER3=(1,20,TOT=(22,1,ZD,EDIT=(IT)),                 
                 TOT=(23,1,ZD,EDIT=(IT)),                 
                 TOT=(24,1,ZD,EDIT=(IT)),                 
                 TOT=(25,1,ZD,EDIT=(IT))))                 
/*                                                         


The output of this is

Code:

NEWYORK     SONY     5 2 2 1
NEWYORK     REDIFF   4 0 4 0
ALABAMA     YAHOO    5 2 2 1

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


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Fri Sep 18, 2009 12:27 am    Post subject: Reply with quote

Thanks kolusu for your solution. It is working great. I am getting following output

Code:
----+----1----+----2 1 0 0 0 
NEWYORK     SONY     5 2 2 1 
NEWYORK     REDIFF   4 0 4 0 
ALABAMA     YAHOO    5 2 2 1 


How to remove the first record
_________________
Thanks
Madhu Sudhan
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 Sep 18, 2009 8:30 am    Post subject: Reply with quote

psmadhusudhan,

bonk The first line is with COLS ON just to show the position of the fields. Just delete it from the input.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Fri Sep 18, 2009 9:47 am    Post subject: Reply with quote

oops sorry for that. Thank you very much for solution.
_________________
Thanks
Madhu Sudhan
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