View previous topic :: View next topic
|
Author |
Message |
thunderstorm
New User
Joined: 23 Mar 2007 Posts: 35 Location: pune
|
|
|
|
Hi All,
I have a file
Key 1
aaaaa bbbbbbccc
aaaaa cccccccccc
bbbbb dddddddd
bbbbb aaaaaaaa
...
I would like to have a count on the key 1 for different keys , for example how many records with key as "aaaaa" , "bbbbb"
I tried doing that thru TRAILER but its not working.
Can you help me ? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
thunderstorm,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
aaaaa bbbbbbccc
aaaaa cccccccccc
bbbbb dddddddd
bbbbb aaaaaaaa
//OUT DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN) LIST(OUT) ON(1,5,CH) ON(VALCNT) BLANK
/*
|
OUT will have:
Code: |
(1,5,CH) VALUE COUNT
aaaaa 2
bbbbb 2
|
You can change the appearance of the report if you need to.
Note: You could do this with SECTIONS, TRAILER3 and COUNT, but OCCUR is easier to use. |
|
Back to top |
|
|
thunderstorm
New User
Joined: 23 Mar 2007 Posts: 35 Location: pune
|
|
|
|
Thanks Frank...this was perfect and solved my issue |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hey Frank,
Tell me one thing, everytime I read your suggestion/s I get a new term to learn about.
How do you know such things about SORT & all other tools..!!
This time exclamation is for 'ON(VALCNT)' ..how do you know that this will give a header 'VALUE COUNT' in the output.
You are marvelous man..I read the manuals..yeah..still did not applied all the tricks..but soon will eat them.
Keep me exclaming..!! |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Anuj,
Quote: |
How do you know such things about SORT & all other tools..!! |
Actually, I only know about the functions of DFSORT and DFSORT's ICETOOL. And the reason is simple: I developed the functions I know about. I "invented" ICETOOL and many of the functions in DFSORT and did the design, code, test and documentation, so I know them from the ground up. |
|
Back to top |
|
|
mahmed
New User
Joined: 23 Apr 2007 Posts: 4 Location: LOS ANGELES, CA
|
|
|
|
Frank,
I have a similar requirement but I need to sort the record on some key and write a count of record with the same key at the end of the record.
How to I do that? Thanks in advance. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
mahmed,
It's not clear to me what you want to do. Please show an example of your input records and what you want for output. Also, give the RECFM and LRECL of the input file and the starting position, length and format of the key. |
|
Back to top |
|
|
mahmed
New User
Joined: 23 Apr 2007 Posts: 4 Location: LOS ANGELES, CA
|
|
|
|
Frank,
I have a 130 byte FB record which looks some thing like this.
Key 1 X(10)
data 1 x(20)
Key 2 x(30)
data 2 x(60)
Filler x(5)
Rec_count 9(5)
I want to sort the file on Key1 and Key2 and remove the duplicates.
In addtion to that I want to write the count of records with the same key1 and Key2 in the field Rec_count i.e if there is only one record I will write 1 and if there are duplicate records I will write that number.
I hope I am clear. I appreciate your help.
Thanks
Ahmed |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Ahmed,
Here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/130)
//SORTOUT DD DSN=... output file (FB/130)
//SYSIN DD *
OPTION ZDPRINT,EQUALS
INREC OVERLAY=(126:C'00001')
SORT FIELDS=(1,10,CH,A,31,30,CH,A)
SUM FIELDS=(126,5,ZD)
/*
|
|
|
Back to top |
|
|
mahmed
New User
Joined: 23 Apr 2007 Posts: 4 Location: LOS ANGELES, CA
|
|
|
|
Frank,
Thanks for the quick reply.
I tried it and am getting this error message..
Code: |
ICE000I J - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL
OPTION ZDPRINT,EQUALS
INREC OVERLAY=(126:C'00001')
$
ICE104A M INVALID INREC OR OUTREC STATEMENT OPERAND
SORT FIELDS=(26,8,CH,A,4,10,CH,A)
SUM FIELDS=(126,5,ZD)
ICE052I J END OF DFSORT
|
Thanks
Ahmed |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I can't tell if you have at least one space before OPTION, INREC, etc. If not, you need one or more spaces, e.g. bbINREC where b is a blank.
If you do have the spaces (which I'm guessing you do), then the error message indicates your site has not installed DFSORT R14 PTF UQ95213 which has been available since Dec, 2004 and is needed to use OVERLAY. Ask your system programmer to install DFSORT R14 PTF UK90006 (April, 2006). That will get you all of the available DFSORT function.
Alternatively, this INREC statement will probably work:
Code: |
INREC FIELDS=(1,125,126:C'00001')
|
|
|
Back to top |
|
|
mahmed
New User
Joined: 23 Apr 2007 Posts: 4 Location: LOS ANGELES, CA
|
|
|
|
Frank,
The OVERLAY did not work with the spaces too. May be our shop doesn't have the required patch yet. I will heva to check with the Systems Programmer. But, the second INREC worked fine though.
Thank you very much. .
Ahmed |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
If the OVERLAY didn't work with spaces in front of the INREC, then you are missing the Dec, 2004 PTF. |
|
Back to top |
|
|
|