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

Count Based on the Key


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

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Tue Apr 17, 2007 10:15 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Apr 17, 2007 11:07 pm
Reply with quote

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
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Tue Apr 17, 2007 11:39 pm
Reply with quote

Thanks Frank...this was perfect and solved my issue
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Apr 18, 2007 2:32 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 18, 2007 8:45 pm
Reply with quote

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
View user's profile Send private message
mahmed

New User


Joined: 23 Apr 2007
Posts: 4
Location: LOS ANGELES, CA

PostPosted: Tue Apr 24, 2007 10:23 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 25, 2007 1:17 am
Reply with quote

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
View user's profile Send private message
mahmed

New User


Joined: 23 Apr 2007
Posts: 4
Location: LOS ANGELES, CA

PostPosted: Wed Apr 25, 2007 1:50 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 25, 2007 2:17 am
Reply with quote

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
View user's profile Send private message
mahmed

New User


Joined: 23 Apr 2007
Posts: 4
Location: LOS ANGELES, CA

PostPosted: Wed Apr 25, 2007 3:08 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 25, 2007 3:14 am
Reply with quote

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
View user's profile Send private message
mahmed

New User


Joined: 23 Apr 2007
Posts: 4
Location: LOS ANGELES, CA

PostPosted: Wed Apr 25, 2007 4:02 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 25, 2007 4:32 am
Reply with quote

If the OVERLAY didn't work with spaces in front of the INREC, then you are missing the Dec, 2004 PTF.
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 To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top