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
 

 

To get the count of records using SORT

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

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Thu Aug 21, 2008 4:12 pm    Post subject: To get the count of records using SORT
Reply with quote

I have a input data as shown below,

142|000001
412|000001
313|000001
142|000001
142|000001
142|000001

I want ouput as shown below,

142|000004
412|000001
313|000001

Please help me in doing so using sort.

Regards,
Priya.
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Aug 21, 2008 4:19 pm    Post subject: Reply to: To get the count of records using SORT
Reply with quote

Priya,

Quote:
Please help me in doing so using sort.


This was disucssed recently. Check this link

http://ibmmainframes.com/viewtopic.php?t=33504
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Aug 21, 2008 4:32 pm    Post subject: Reply to: To get the count of records using SORT
Reply with quote

Priya,

use this JCL

Code:
//S1 EXEC PGM=ICEMAN                           
//SYSOUT   DD SYSOUT=*                         
//SORTIN DD *                                   
142|000001                                     
412|000001                                     
313|000001                                     
142|000001                                     
142|000001                                     
142|000001                                     
/*                                             
//SORTOUT DD SYSOUT=*                           
//SYSIN   DD   *                               
  SORT FIELDS=(1,3,CH,A)                       
  OUTFIL REMOVECC,NODETAIL,                     
  SECTIONS=(1,3,                               
   TRAILER3=(1,4,5:COUNT=(M11,LENGTH=6)))       
/*                                             



Output:

Code:
142|000004
313|000001
412|000001


Please note that i have sorted the output based on the first 3 bytes inorder to make SECTIONS work.

The order of records in the output is different from what you have posted.Let me know if this order is OK.
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Thu Aug 21, 2008 5:17 pm    Post subject:
Reply with quote

Hi Aaru,

Thanks a lot. It really worked.

It would be great if you let me know the significance of each commands.

Regards,
Priya.
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: Thu Aug 21, 2008 8:42 pm    Post subject:
Reply with quote

Priya,

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/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Aug 22, 2008 11:18 am    Post subject: Reply to: To get the count of records using SORT
Reply with quote

Priya,

Quote:
Thanks a lot. It really worked.


You are welc icon_biggrin.gif me.

Quote:
It would be great if you let me know the significance of each commands.


As Frank suggested, read the manual as all these commands are explained very well.



Code:
SORT FIELDS=(1,3,CH,A) 


First the input records are sorted based on the first 3 bytes.The SORT statement sorts on the first 3 bytes to bring all of the records for each value together, so only one section is produced for each value.



Code:
OUTFIL REMOVECC,NODETAIL,


From the manuals for REMOVECC

Quote:
REMOVECC tells DFSORT to remove the carriage control character from the first byte of each record. As a result, the data starts in column 1 of the report rather than in column 2.


NODETAIL

Quote:
NODETAIL tells DFSORT to process the data records in the usual way, but not to write them to the report data set.


Code:
SECTIONS=(1,3,   


SECTION parameter is used to divide the output into sections by the first 3 bytes. 1,3 tells DFSORT to start a new section every time the value in columns 1-3 changes.

Code:
TRAILER3=(1,4,5:COUNT=(M11,LENGTH=6)))


TRAILER3 - Is for section trailers
1,4 - First 4 bytes are written to the output
COUNT - Prints a message containing the count of records in a data set.
M11 - edit mask with the pattern as TTTTTTTTTTTTTTT. This is used as per your reqts.
LENGTH=6 - As you wanted only 6 bytes for the count.



Hope this helps. Post if you still have any query.
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


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