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

get the count of matching combination - ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 11, 2011 2:59 pm
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: 1742
Location: Tirupur, India

PostPosted: Mon Jul 11, 2011 2:59 pm
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
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 11, 2011 3:08 pm
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
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 11, 2011 3:27 pm
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
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: 1742
Location: Tirupur, India

PostPosted: Mon Jul 11, 2011 4:47 pm
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.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: 577
Location: USA

PostPosted: Mon Jul 11, 2011 7:35 pm
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 Developer


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

PostPosted: Tue Jul 12, 2011 1:21 am
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:

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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 12, 2011 2:33 pm
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
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
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 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 Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top