|
View previous topic :: View next topic
|
| Author |
Message |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
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
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What about the length of the number? Can there be only 3 matches maximum, or can there be 1,000,000+? |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
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:
Note:
Output file is FBA.
Hope it helps. |
|
| Back to top |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
| It can be 10,00,000+ |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
| It can be in any order |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
thanks Vasanthz, I tried the code you provided.
It works fine.
In the output
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 |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
| 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
Thanks, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
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
It should be like
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
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 |
|
 |
mksranjani
New User
Joined: 03 Feb 2010 Posts: 29 Location: Chennai
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|