Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Count Based on the Key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Count Based on the Key
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 Moderator


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

PostPosted: Tue Apr 17, 2007 11:07 pm    Post subject:
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    Post subject:
Reply with quote

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

Senior Member


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

PostPosted: Wed Apr 18, 2007 2:32 pm    Post subject:
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 Moderator


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

PostPosted: Wed Apr 18, 2007 8:45 pm    Post subject:
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    Post subject: Re: Count Based on the Key
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 Moderator


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

PostPosted: Wed Apr 25, 2007 1:17 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Apr 25, 2007 2:17 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Apr 25, 2007 3:14 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Apr 25, 2007 4:32 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us