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
 

 

get the count of matching combination - ICETOOL

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

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Mon Jul 11, 2011 12:36 pm    Post subject: get the count of matching combination - ICETOOL
Reply with quote

Hi,

I have a file with LRECL 300. It is a report file. In the position 257 : 262, there is data like below

ABC001 starts at position 257

Code:

ABC001      JKEHFKNDVJWVMFGRB
ABC001      FBREBHEFBRGFBTBGG
ABC001      REGFEVRHGERVERGRE
ABC002      GREGERGRBGETBHTBB
ABC002      GREVBRGREGGRRGGRE


I need to get the count of records with matching combination in position
257 : 262 and write to a output file

The output should be like

Code:

ABC001           3
ABC002           2


Explanation : ABC001 occurs 3 times. hence the count 3
ABC002 occurs 2 times. hence the count 2

Can this be done through DFSORT or ICETOOL ?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Mon Jul 11, 2011 2:59 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

What about the length of the number? Can there be only 3 matches maximum, or can there be 1,000,000+?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 11, 2011 2:59 pm    Post subject:
Reply with quote

Hello,
You could try the below program, but the output maynot be entirely what you are looking for.

Code:
//JS010    EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//SORTIN   DD DISP=SHR,DSN=WELLS.SORTIN                   
//SORTOUT  DD DISP=OLD,DSN=WELLS.SORTOUT                 
//SYSOUT   DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  OCCUR FROM(SORTIN) LIST(SORTOUT) ON(257,6,CH)  ON(VALCNT) -
  NOHEADER BLANK                                           
/*                                       

Output:
Code:
ABC001                 3
ABC002                 2


Note:
Output file is FBA.

Hope it helps.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Mon Jul 11, 2011 3:00 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

It can be 10,00,000+
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Mon Jul 11, 2011 3:08 pm    Post subject: Re: Reply to: get the count of matching combination - ICETOO
Reply with quote

mksranjani wrote:
It can be 10,00,000+


Nice to know :-)

So, it is a big file. You want to make sure you get it right first time with your test data. What order do you want the output in? Not a big thing, because you could always do it later.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Mon Jul 11, 2011 3:16 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

It can be in any order
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Mon Jul 11, 2011 3:27 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

OK, so give Vasanthz's code a whirl with your test data. Let us know. It would be worth keeping a check on this topic, as there might be other solutions suiting your file size, who know's?

If you're OK with Vasanthz's code, make sure you look up everything and understand what it is doing. Note the comment about FBA for the output.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Mon Jul 11, 2011 3:27 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

thanks Vasanthz, I tried the code you provided.
It works fine.

In the output

Code:

 ABC001                 3                                               
 ABC002                 2                                               


output data starts at the 2nd position. can you please tell me the reason for why it has not started at the 1st position. Also, about the spacing between the data and the count.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 11, 2011 4:47 pm    Post subject:
Reply with quote

Hello,
Quote:
output data starts at the 2nd position. can you please tell me the reason for why it has not started at the 1st position.

The first byte of FBA dataset has ASA print control characters. I am not aware of creating a FB dataset by using OCCUR operator, maybe some of the SORT experts could provide you a better solution.

I tried the USING keyword with OCCUR, but looks like USING is not supported with OCCUR operator. :S

You can get information about indent,spacing of the fields of ICETOOL OCCUR operator from,
ftp://ftp.software.ibm.com/storage/dfsort/mvs/sorttool.pdf

Hope it helps.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Jul 11, 2011 7:35 pm    Post subject:
Reply with quote

mksranjani wrote:
Hi,

I have a file with LRECL 300. It is a report file. In the position 257 : 262, there is data like below
ABC001
ABC001
ABC001
ABC002
ABC002

I need to get the count of records with matching combination in position
257 : 262 and write to a output file

The output should be like
3
2

Explanation : ABC001 occurs 3 times. hence the count 3
ABC002 occurs 2 times. hence the count 2

Can this be done through ICETOOL ?

mksranjani,
Assuming your input file is NOT sorted on Key fields(257 through 262),see if below helps.
Code:

//STEP0001  EXEC PGM=SORT                                 
//SYSOUT    DD SYSOUT=*                                   
//SYSPRINT  DD SYSOUT=*                                   
//SORTIN    DD DISP=SHR,DSN=YOUR INPUT FILE               
//SORTOUT   DD SYSOUT=*                                   
//SYSIN    DD *                                           
 SORT FIELDS=(257,6,CH,A),EQUALS                           
 OUTFIL REMOVECC,NODETAIL,SECTIONS=(257,6,                 
                 TRAILER3=(257,6,X,COUNT=(M10,LENGTH=08)))
/*                                                         


Or if you file is already sorted in Key (257 through 262) then replace SORT FIELDS=(257,6,CH,A),EQUALS with SORT FIELDS=COPY. If you don't want leading zeros suppressed then replace M10 with M11. Here X in the TRAILER3 controls spacing between your key fields and count. If you want 2 spaces use 2X and so on.

OUTPUT
Code:
ABC001        3
ABC002        2


Thanks,
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 Jul 12, 2011 1:21 am    Post subject:
Reply with quote

Quote:
I am not aware of creating a FB dataset by using OCCUR operator, maybe some of the SORT experts could provide you a better solution.


You can use OCCUR's NOCC option to create an FB file (without the carriage control character) instead of an FBA file (with the carriage control character).

You can use OCCUR's BETWEEN(n) option to change the number of spaces between columns.

You can also use various OCCUR formatting options to edit the VALCNT value.

For complete details on the OCCUR operator of DFSORT's ICETOOL, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA50/7.11?DT=20100630155256
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Tue Jul 12, 2011 11:10 am    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

Thanks sqlcode1, I tried the code you provided. The output data starts at the 2nd position.

Code:

//STEP0001  EXEC PGM=SORT                                             
//SYSOUT    DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SORTIN    DD DISP=SHR,DSN=input ifle
//SORTOUT  DD DSN=output.file(+1),             
//          DISP=(,CATLG,DELETE),                                     
//          UNIT=TESTDA,                                             
//          SPACE=(CYL,(50,100),RLSE),                               
//          DCB=(BC.MODEL,RECFM=FB,LRECL=286,BLKSIZE=0)               
//SYSIN    DD *                                                       
 SORT FIELDS=COPY                                                     
 OUTFIL REMOVECC,NODETAIL,SECTIONS=(257,6,                           
                 TRAILER3=(257,6,X,COUNT=(M10,LENGTH=08)))           
/*   


The output looks like

Code:

 ABC00        3                                                         
 ABC00        2                                                         


It should be like
Code:

ABC001        3                                                         
ABC002        2                                                         
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Tue Jul 12, 2011 2:33 pm    Post subject: Re: Reply to: get the count of matching combination - ICETOO
Reply with quote

You are writing to a dataset, with a curious LRECL for this output.

First try your SORTOUT as SYSOUT=* please, then it is the same as sqlcode1's example.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Tue Jul 12, 2011 3:02 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

Thanks everyone for giving solutions. There was a mistake from my side. That's y the output was starting at the second position.
Im not sure of the format of the input file. Data ABC001 was at position 257 in the input file. But only when I changed the position of the sort field as 258 : 6 , it worked fine. the output started at the first position

Code:
//STEP0001  EXEC PGM=SORT                                             
//SYSOUT    DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SORTIN    DD DISP=SHR,DSN=input.file
//SORTOUT  DD DSN=output.file(+1),             
//          DISP=(,CATLG,DELETE),                                     
//          UNIT=TESTDA,                                             
//          SPACE=(CYL,(50,100),RLSE),                               
//          DCB=(BC.MODEL,RECFM=FB,LRECL=287,BLKSIZE=0)               
//SYSIN    DD *                                                       
 SORT FIELDS=(258,6,CH,A),EQUALS                                     
 OUTFIL REMOVECC,NODETAIL,SECTIONS=(258,6,                           
                 TRAILER3=(258,6,X,COUNT=(M10,LENGTH=09)))           
/*   


The output I got

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
ABC001         3                                                       
ABC002         2                                                       
**************************** Bottom of Data ****************************                                                 


[/code]
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Tue Jul 12, 2011 3:08 pm    Post subject: Reply to: get the count of matching combination - ICETOOL
Reply with quote

The solution which Vasanth gave using Icetool also worked fine when I changed the position of the sort fields.

Thanks again. It wsa a good learning.
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 Matching with Key at different postions. rajatbagga DFSORT/ICETOOL 12 Wed Nov 09, 2016 10:58 am
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts ICETOOL/SYNCSORT - SYSPRINT output nartcr DFSORT/ICETOOL 17 Wed Oct 05, 2016 10:46 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


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