View previous topic :: View next topic
|
Author |
Message |
shivani_jha
New User
Joined: 12 Feb 2007 Posts: 11 Location: mumbai
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
anand_smail
New User
Joined: 05 Jun 2005 Posts: 13
|
|
|
|
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 |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
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 |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|