|
View previous topic :: View next topic
|
| Author |
Message |
ballaswaroop
New User
Joined: 20 Sep 2005 Posts: 25
|
|
|
|
I've a file which has the following Data
IMA06010
IMA06010
IMA06010
IMA06010
IMA06010
IMA06012
IMA06012
IMA06012
IMA06012
IMA06012
IMA06018
IMA06018
IMA06018
IMA06018
IMB06122
IMB06122
IMB06122
I would like to have the O/P as
IMA - 6010 - Count = 5
IMA - 6012 - Count = 5
IMA - 6018 - Count = 4
IMB - 6122 - Count = 3 |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Have you looked at ICETOOL's OCCURS operator? |
|
| Back to top |
|
 |
hailashwin
New User

Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
One way of doing this could be as below, but might not be the most efficient way..
| Code: |
//STEP010 EXEC PGM=ICETOOL
//*
//TOOLMSG DD SYSOUT=*
//SSMSG DD SYSOUT=*
//*
//SORTIN DD *
IMA06010
IMA06010
IMA06010
IMA06010
IMA06010
IMA06012
IMA06012
IMA06012
IMA06012
IMA06012
IMA06018
IMA06018
IMA06018
IMA06018
IMB06122
IMB06122
IMB06122
//*
//CTL3JNF1 DD DSN=X1,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE)
//*
//CTL3JNF2 DD DSN=X2,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE)
//TOOLIN DD *
SORT FROM(SORTIN) TO(CTL3JNF1) USING(CTL1)
SORT FROM(CTL3JNF1) TO(CTL3JNF2) USING(CTL2)
//*
//CTL1CNTL DD *
OPTION COPY
INREC OVERLAY=(79:C'1')
OUTFIL FNAMES=CTL3JNF1,REMOVECC,
SECTIONS=(5,4,
TRAILER3=(1,3,C'-',5,4,C'-COUNT=',TOT=(79,1,ZD)))
//*
//CTL2CNTL DD *
OPTION COPY
INCLUDE COND=(4,1,CH,EQ,C'-')
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))
//*
//SYSOUT DD SYSOUT=*
|
Thanks,
Ashwin. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| hailashwin wrote: |
One way of doing this could be as below, but might not be the most efficient way..
|
hailashwin,
I appreciate your enthusiasm on providing solutions but if do think it is not efficient solution, please refrain from posting it. As Bill mentioned earlier you can use OCCUR operator or simple reporting features in DFSORT to get the desired results.
You don't need 2 passes of data to get the desired results. You Just need the parm NODETAIL. Check this link which explains in detail about NODETAIL
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ice1ca60/3.15
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
IMA06010
IMA06010
IMA06010
IMA06010
IMA06010
IMA06012
IMA06012
IMA06012
IMA06012
IMA06012
IMA06018
IMA06018
IMA06018
IMA06018
IMB06122
IMB06122
IMB06122
//RPT DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN) LIST(RPT) -
DATE TITLE('COUNTS BY ID AND SEQUENCE') TIME PAGE -
BLANK -
HEADER('ID') ON(1,3,CH) -
HEADER('SEQUENCE') ON(5,4,CH) -
HEADER('COUNT') ON(VALCNT,A1)
//* |
The output from this job is
| Code: |
03/06/14 COUNTS BY ID AND SEQUENCE 10:34:57 - 1 -
ID SEQUENCE COUNT
--- -------- --------------------
IMA 6010 5
IMA 6012 5
IMA 6018 4
IMB 6122 3
|
Alternatively you can use the following JCL with reporting features.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
IMA06010
IMA06010
IMA06010
IMA06010
IMA06010
IMA06012
IMA06012
IMA06012
IMA06012
IMA06012
IMA06018
IMA06018
IMA06018
IMA06018
IMB06122
IMB06122
IMB06122
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,3,5,4,
TRAILER3=(1,3,' - ',5,4,' - COUNT = ',COUNT))
//* |
The output from this is
| Code: |
IMA - 6010 - COUNT = 5
IMA - 6012 - COUNT = 5
IMA - 6018 - COUNT = 4
IMB - 6122 - COUNT = 3
|
|
|
| Back to top |
|
 |
ballaswaroop
New User
Joined: 20 Sep 2005 Posts: 25
|
|
|
|
Thank You !
Part - 2 Of the requirement is to generate a alert when the count falls below a tresh hold
Eg:
IMA - 6010 - COUNT = 5
IMA - 6012 - COUNT = 5
IMA - 6018 - COUNT = 4
IMB - 6122 - COUNT = 3
If IMA - 6012 - COUNT = 5 ie row 2 falls below 3 for example we would like to generate a alert by sending email to the concern team. Will that be possible to do the validation via SORT ? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If all that you require can be done by manipulating data in files, then probably Yes.
Specifically to your question, we can't know, as your question is far too general. |
|
| Back to top |
|
 |
ballaswaroop
New User
Joined: 20 Sep 2005 Posts: 25
|
|
|
|
If the count in any particular row falls below a tresh hold I want to generate an alert.
eg: if for row 2 IMSA-6012-Count=5 falls below a pre defined treshold say 3 then I want a alert say email to be triggered.
Let me know if you need any more details. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Let's say you have a file containing your e-mail, such that by writing it to a sysout dataset with the appropriate settings, it will be sent (or to any file which will be processed afterwards would also be fine).
Let's say you have a file from which you can select data which requires an e-mail to be sent.
It would then be possible to use a cartesian join with JOINKEYS to output, modified if necessary, e-mails for records matching selection criteria.
So if you have, or can get, e-mails working in that way for you, the rest will be quite simple.
This is what I meant earlier. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| ballaswaroop wrote: |
| Part - 2 Of the requirement is to generate a alert when the count falls below a tresh hold |
So when is Part -3 or Part -4 or Part - n requirement coming up? I always wonder why people show a part of the requirement and when a solution is provided for the specific task they change it or keep on appending requirements to it which makes the solution a moot.
| ballaswaroop wrote: |
If the count in any particular row falls below a tresh hold I want to generate an alert.
eg: if for row 2 IMSA-6012-Count=5 falls below a pre defined treshold say 3 then I want a alert say email to be triggered.
Let me know if you need any more details. |
Take a look at Hailashwin's solution and take the first part of it where he appends a "1" to every record. You need to expand it and sum on it and use OUTFIL Include/Omit and get the desired results. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|