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 no.of occurrences

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Jul 10, 2012 4:03 pm    Post subject: count no.of occurrences
Reply with quote

Hi,

I have a file (LRECL=80, RECFM=FB) with data to count no.of occurrences of a word "ORDER" appearing somewhere in each line.

Code:

DATA00001000ORDER
DATAORDER01003903
DATA39ORDER394301
DATA0975ORDER1930


Output:
Code:

ORDER 4


Please let me know how to get it done using OCCURS operator of DFSORT.....we are using Z/OS DFSORT V1R10.

Thanks.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Jul 10, 2012 4:07 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

Do you mean OCCURS of ICETOOL?

Why not INCLUDE/OMIT with SS, and use reporting functions of OUTFIL to produce a TRAILERn with your COUNT and text, using NODETAIL and REMOVECC?

There are examples here.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Jul 10, 2012 4:16 pm    Post subject:
Reply with quote

Bill, what should I omit? All the records have ORDER appearing somewhere in it !!!

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Jul 10, 2012 4:17 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

So are you really saying you want to know how many records there are on the file, since that is what it comes down to if all contain the text "ORDER"?
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Jul 10, 2012 4:19 pm    Post subject:
Reply with quote

Code:

//STEPONE1 EXEC PGM=ICETOOL                         
//SYSOUT   DD SYSOUT=*                               
//TOOLMSG  DD SYSOUT=*                               
//DFSMSG   DD SYSOUT=*                               
//IN       DD *                                     
ABC001      JKEHFKNDVJWVMFGRB                       
ABC001      FBREBHEFBRGFBTBGG                       
ABC001      REGFEVRHGERVERGRE                       
ABC002      GREGERGRBGETBHTBB                       
ABC002      GREVBRGREGGRRGGRE                       
//OUT      DD SYSOUT=*                               
//TOOLIN   DD *                                     
  OCCUR FROM(IN) LIST(OUT) ON(1,6,CH)  ON(VALCNT) - 
  NOHEADER BLANK                                     
/*                                                   


In fact, I found above example in this forum but don't know how to adjust it to my requirement. Because, in my case, ORDER is appearing at different places icon_sad.gif

Please help.

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Jul 10, 2012 4:24 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

Have you looked at the manual? You can't just find a "solution" to something and hope that you can tweak it to become a "solution" to your problem.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 9:39 pm    Post subject:
Reply with quote

Hello,

Why do you believe you need to use OCCURS?

If ORDER is in Every record, why do you need to do anything other than get the count?

Did you read about SS (which will accommodate the changing position of the ORDER value)?

You posted a solution for something maybe similar, but not the output from the run. . .

The biggest part of getting help from a forum is what you provide for the helpers to work with.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 10, 2012 9:47 pm    Post subject:
Reply with quote

ramsri,

Use the following JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                             
DATA00001000ORDER                           
DATAORDER01003903                           
DATA39ORDER394301                           
DATA0975ORDER1930                           
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                             
  INCLUDE COND=(1,80,SS,EQ,C'ORDER')       
  SORT FIELDS=COPY                         
  INREC BUILD=(C'O')                       
  OUTFIL REMOVECC,NODETAIL,BUILD=(16X),     
  TRAILER1=('ORDER ',COUNT=(M10,LENGTH=10))
//*
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 11, 2012 8:22 am    Post subject: Reply to: count no.of occurrences
Reply with quote

Kolusu, thank you very much for the trick......now, we at least know that OCCURS has got some limitations and could not do this !

Thanks again.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 11, 2012 2:06 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

Hi,

Is it possible to modify this solution to get count of more than one?

Input:
Code:

DATA00001000ORDER
DATAORDER01003903
BATA39ORDER394301
DATA0975ORDER1930


Output:
Code:

ORDER 3
BATA  1


Thanks.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Wed Jul 11, 2012 2:14 pm    Post subject:
Reply with quote

What does your reading of the manual and your experiments tell you?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jul 11, 2012 2:18 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

I see four ORDERs. What would be the rules for getting your count to 3?
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 11, 2012 3:25 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

Yes Bill.......sorry for the typo......

Output:
Code:

ORDER 4
BATA  1


Thanks.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jul 11, 2012 3:30 pm    Post subject:
Reply with quote

And now you have 5 records, instead of 4.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Jul 11, 2012 3:39 pm    Post subject:
Reply with quote

Peter, some records have both icon_smile.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jul 11, 2012 3:42 pm    Post subject:
Reply with quote

Arun Raj wrote:
Peter, some records have both icon_smile.gif


Sure Arun, we all know that. But how about the end user (if there is one)?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jul 11, 2012 4:28 pm    Post subject: Reply to: count no.of occurrences
Reply with quote

You need two counts for your values. These can be at the "front" of the record as you don't need the data.

Use IFOUTLEN to limit the size of the record to your counts.

Use IFTHEN=(WHEN=INIT to initialise your counts

Use IFTHEN=(WHEN=(logexp) with SS to find each field and set count to 1, remembering to use HIT=NEXT on the first.

Use the reporting functions to add up the fileds and format your desired output.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jul 11, 2012 10:03 pm    Post subject:
Reply with quote

ramsri,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
DATA00001000ORDER                                               
DATAORDER01003903                                               
BATA39ORDER394301                                               
DATA0975ORDER1930                                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  INCLUDE COND=(1,80,SS,EQ,C'ORDER',OR,                         
                1,80,SS,EQ,C'BATA')                             
                                                               
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=2,IFTHEN=(WHEN=INIT,BUILD=(2C'0',1,80)),       
  IFTHEN=(WHEN=(3,80,SS,EQ,C'ORDER'),OVERLAY=(1:C'1'),HIT=NEXT),
  IFTHEN=(WHEN=(3,80,SS,EQ,C'BATA'),OVERLAY=(2:C'1'))           
                                                               
  OUTFIL REMOVECC,NODETAIL,BUILD=(16X),                         
  TRAILER1=('ORDER ',TOT=(1,1,ZD,M10,LENGTH=10),/,             
            'BATA  ',TOT=(2,1,ZD,M10,LENGTH=10))               
//*
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Jul 12, 2012 8:22 am    Post subject: Reply to: count no.of occurrences
Reply with quote

Hi Kolusu, thanks a lot for this useful sort card icon_biggrin.gif
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 abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Update the Sortout file with record c... karthik_sripal SYNCSORT 8 Tue May 17, 2016 8:52 pm
No new posts CQM : Exec count is 0 but getpages &g... soundarr DB2 1 Thu Mar 17, 2016 10:08 pm
No new posts JCL SORT to split the file and put re... Bill Woodger DFSORT/ICETOOL 17 Wed Feb 17, 2016 4:17 pm


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