View previous topic :: View next topic
|
Author |
Message |
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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:
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Bill, what should I omit? All the records have ORDER appearing somewhere in it !!!
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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
Please help.
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Hi,
Is it possible to modify this solution to get count of more than one?
Input:
Code: |
DATA00001000ORDER
DATAORDER01003903
BATA39ORDER394301
DATA0975ORDER1930
|
Output:
Thanks. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
What does your reading of the manual and your experiments tell you? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I see four ORDERs. What would be the rules for getting your count to 3? |
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Yes Bill.......sorry for the typo......
Output:
Thanks. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
And now you have 5 records, instead of 4. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Peter, some records have both |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Arun Raj wrote: |
Peter, some records have both |
Sure Arun, we all know that. But how about the end user (if there is one)? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Hi Kolusu, thanks a lot for this useful sort card |
|
Back to top |
|
|
|