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

How to find Count of some records using SORT utility


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Tue Feb 13, 2007 12:01 pm
Reply with quote

hi

I want to find the count and sum of all X type of records of a file using SORT utility. I have X, Y and Z type of records in file.

How can I get the output which should have count of X records Sum of X records
Count of Y records and Sum of Y records in this pattern.

Shivani
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: Tue Feb 13, 2007 9:46 pm
Reply with quote

What is the RECFM and LRECL of your input file. What is the starting position, length and format of the relevant fields? Please show an example of your input records and the records you expect for output.
Back to top
View user's profile Send private message
anand_smail

New User


Joined: 05 Jun 2005
Posts: 13

PostPosted: Fri Feb 23, 2007 12:57 pm
Reply with quote

shivani_jha wrote:
hi

I want to find the count and sum of all X type of records of a file using SORT utility. I have X, Y and Z type of records in file.

How can I get the output which should have count of X records Sum of X records
Count of Y records and Sum of Y records in this pattern.

Shivani

Do you got the answer to this question?
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Fri Feb 23, 2007 1:44 pm
Reply with quote

Here you go.

(SYNCSORT)
Code:

//PS010   EXEC PGM=SYNCSORT         
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                     
AAA     11                           
AAA     22                           
BBB     11                           
BBB     22                           
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                     
  SORT FIELDS=(1,3,CH,A)             
  SUM FIELDS=(9,2,ZD)               


Code:


SYSOUT  :
AAA     33
BBB     33

Thanks
Krishy
[/code]
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Fri Feb 23, 2007 1:54 pm
Reply with quote

Sorry,
Please change the control card as below to get the total number of records as well.

Code:

INREC FIELDS=(1,20,21:C'00001')
SORT FIELDS=(1,3,CH,A)         
SUM FIELDS=(9,2,ZD,21,5,ZD)   


Sysout :

Code:


AAA     33          00002
BBB     33          00002


Thanks
Krishy
[/code]
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: Fri Feb 23, 2007 9:55 pm
Reply with quote

If that's the requirement (and we don't know that it is), here's a more efficient way to do it (copy vs sort) with DFSORT:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
AAA     11
AAA     22
BBB     11
BBB     22
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,3,
      TRAILER3=(1,3,X,
       TOT=(9,2,ZD,M11,LENGTH=5),X,
       COUNT=(M11,LENGTH=5)))
/*
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 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
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top