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

To get the count of records using SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1287
Location: Chennai, India

PostPosted: Thu Aug 21, 2008 4:19 pm
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: 1287
Location: Chennai, India

PostPosted: Thu Aug 21, 2008 4:32 pm
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
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 Developer


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

PostPosted: Thu Aug 21, 2008 8:42 pm
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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Aaru

Senior Member


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

PostPosted: Fri Aug 22, 2008 11:18 am
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 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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top