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

To calculate size occupied by a job


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Wed Mar 18, 2009 5:47 pm
Reply with quote

Hi friends,
I want to write a tool in rexx which will calculate the space occupied by all the jobs present in the spool (S.H).
Can any one help me to get the space occupied by a job.
Will the size of the jobs be stored in any system datasets?

please let me know if any other details required!


Thanks,
Balu
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Mar 18, 2009 6:08 pm
Reply with quote

What do you mean by
Quote:
the space occupied by all the jobs present in the spool
?

Do you mean the memory that those jobs used while executing? This is show in message IEF374I for each step or IEF376I for each job.

Or do you mean how much DASD the datasets in the job occupy or occupied?

Or do you mean how much space is occupied in the spoool dataset(s)?


Or maybe something else?

Garry.
[/quote]
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Mar 18, 2009 6:33 pm
Reply with quote

And if you want to use REXX, why post in the JCL forum ?
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Thu Mar 19, 2009 9:57 am
Reply with quote

Hi
What exactly I meant was what is the total space occupied by sysout, sysdump, ceedump, etc.
some thing like this:

Code:

USE6D500 JOB09670 USE6       4,853,897
USE5D500 JOB09108 USE5       5,390,822
USE6D500 JOB09317 USE6       10M     

I need the details as mentioned above
Job Name, Job Id, User Id and total byte count of all the steps in each step of job.

SDSF JOB DATA SET DISPLAY :
Code:

DDNAME   STEPNAME PROCSTEP  BYTE-CNT     
 JESMSGLG JES2               2,151       
 JESJCL   JES2               5,103       
 JESYSMSG JES2               6,314       
 SYSOUT   S100     S001        301       
 SYSUDUMP S100     S001      18M         
 CEEDUMP  S100     S001      319,103     

In the avove We can see the the SYSDUMP has occupied alot of space.
So, my basic intention is to get the jobs which occupied more space. so that we can purge those jobs.

How can we extract all these details in a rexx program. Are they stored in any datasets?
Thanks,
Balu
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Mar 19, 2009 12:21 pm
Reply with quote

The information is stored in the spool, datasets internal to JES. You need to execute SDSF via REXX to get the details.

There are a lot of examples of using SDSF in batch and with REXX on the forum, so start searching .............
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Mon Mar 23, 2009 2:52 pm
Reply with quote

Hi
I am finally succesfull in achieving the requirement.
But when I execute the Rexx command in batch it is throwing the error during the call of 'ISFAFD'
Code:

33 *-* ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,255')"
   +++ RC(-3) +++                                           


Can't we execute ISFEXEC commands in batch? If we can, what changes needs to be done to the following jcl
Code:

//TSOBAT    EXEC PGM=IKJEFT01                       
//SYSEXEC   DD DSN=USER100.TSO.REXX,DISP=SHR       
//SYSTSIN   DD *                                   
 BATSDSF                                           
//SYSTSPRT  DD SYSOUT=*                             

I gave search in the forum, But I didn't get the exact results what I need.

Thanks,Balu
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Mar 23, 2009 3:04 pm
Reply with quote

You need to allocate all of the ISPF libraries that are allocated to your TSO online session to the batch job.

You also need to use the ISPSTART command to invoke your REXX EXEC.

Many examples available on the forum.
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Mon Mar 23, 2009 5:28 pm
Reply with quote

Thanks
I got a Rexx code from this link which creates the jcl

Its working fine.
What I can observe is the time taken when I run through batch is more compared to the direct run as tso rexxcmd.
Is this observation correct or it has nothing to with time?

Thanks,
Balu
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Tue Apr 07, 2009 6:51 pm
Reply with quote

Hi vvmanyam,

I have same requirement. Can you post the JCL used by you to get the output.

Regards,
Ram.
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Thu Apr 09, 2009 8:37 am
Reply with quote

Hi Ram,
What exactly you are looking for?
The JCL to execute the Rexx code with ISPEXEC in Batch or
The Rexx code to get the Jobs in spool and their sizes in a dataset


Regards,
Balu
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 09, 2009 8:43 am
Reply with quote

Hello,

I'm sure that Ram would appreciate both icon_smile.gif

Others with similar requirements could benefit also. . .
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Thu Apr 09, 2009 10:24 am
Reply with quote

Hi,
This is the Rexx code for my requirement which I have mentioned in my first post. This code is slightly big. There might be any other simplar way to get it, but I am quite new to Rexx, so I coded this program with what ever I have learnt by going through this forum and other docs in net.

Code:

/* rexx */                                                                   
/***************************************************************************/
/**The Rexx Code Will Scan through all the jobs in S.H                       
   JOBNAME = CG* of all owners                                               
   and get the details of Byte-Cnt of each step of the job.                   
   If any of the setp of a job has a Byte-Cnt more than '500000'             
   A message will be send to the user asking to purge the jobs               
   Message will be send to only those users who are present in the userfil**/
/***************************************************************************/
  wrkfil1 = Userid()'.TSO.TEST1'                                             
  userfil = 'USR1.TSO.SOURCE(USERIDS)'                                       
           /*Contains the user ids to whom the message to be sent */         
                                                                             
"ALLOC F(ISFIN) TRACKS SPACE(1) REU"            /* Used by SDSF     */       
                                                                             
 "ALLOC DA('"wrkfil1"') F(ISFOUT) NEW DELETE REU " ,                         
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)" /* work files */   
                                                                             
"ALLOC F(TEMPPRT) NEW DELETE REU " ,                                         
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)"                     
  /* read the userfile in to an array */                                         
  "ALLOC DA('"userfil"') F(INFILE) SHR REUSE"                                   
  "EXECIO * DISKR INFILE (STEM USERIDS. FINIS"                                   
  "FREE DDN(infile)"                                                             
do usr = 1 to userids.0                                                         
   userids.usr = SUBSTR(USERIDS.usr,1,4)                                         
end                                                                             
/* First get the First job in S.H */                                             
QUEUE "PRE CG*"                                                                 
QUEUE "H"                                                                       
/* QUEUE "++?" */                                                               
QUEUE "END"                                                                     
"EXECIO" QUEUED()" DISKW ISFIN (FINIS"                                           
  ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,255')"                         
ADDRESS TSO                                                                     
  "ALLOC DA('"wrkfil1"') F(INFILE) SHR REUSE"                                   
  "EXECIO * DISKR INFILE (STEM INAR2. FINIS"                                     
  "FREE DDN(infile)"                                                             
  /* to get the no of jobs in the spool Ex:  LINE 1-7 (7) */                     
   st_pos = pos('(',INAR2.65,1)                                                 
   en_pos = pos(')',INAR2.65,1)                                               
   job_count = substr(INAR2.65,st_pos+1,en_pos-st_pos-1)                     
say 'Total No of jobs in spool :' job_count                                   
/* use '?' to get in to each job and extract the byte-Cnt of each line */     
tjbs = 0                                                                     
do cnt = 0 to job_count-1                                                     
   QUEUE "PRE CG*"                                                           
   QUEUE "H"                                                                 
   QUEUE "down" cnt                                                           
   QUEUE "++?"                                                               
   "EXECIO" QUEUED()" DISKW ISFIN (FINIS"                                     
   ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,255')"                     
                                                                             
   ADDRESS TSO                                                               
   "ALLOC DA('"wrkfil1"') F(INFILE) SHR REUSE"                               
   "EXECIO * DISKR INFILE (STEM INAR2. FINIS"                                 
   "FREE DDN(infile)"                                                         
   tjbs = tjbs + 1                                                           
                                                                             
   stline = inar2.129                                                         
   st_pos = pos('(',stline,55)                                               
   en_pos = pos(')',stline,55)  /* To get no of lines in each job*/         
   job_lct.tjbs = substr(stline,st_pos+1,en_pos-st_pos-1)                   
   Job_name.tjbs= substr(stline,35,8)                                       
   Job_id.tjbs  = substr(stline,45,8)                                       
   job_flag.tjbs  = 'N'                                                     
   job_msize.tjbs = ' '                                                     
   do cnt1 = 1 to Job_lct.tjbs                                               
      tcnt = cnt1 + 131                                                     
        tot_bytes =  substr(inar2.tcnt,87,8)  /* Get the byte count */       
          k = pos('M',tot_bytes)                                             
          if  k > 0 then                                                     
             do       /* Convert the Mega byte count in to Byte count */     
               tot_bytes = substr(tot_bytes,1,k-1) * 1000000                 
               job_flag.tjbs  = 'y'                                         
             end                                                             
          s1 = space(TRANSLATE(tot_bytes,' ',','),0)                         
          s1 = TRANSLATE(s1,'0',' ')                                         
          s2 = TRANSLATE(job_msize.tjbs,'0',' ')                             
           if s1 > s2 then   /* Get the max byte count of all steps */       
             do                                                             
               job_msize.tjbs = s1                                           
             end                                                               
   end                                                                         
end                                                                           
/* Extract only those jobs with byte count more than 500000 */                 
  cnt1 = 0                                                                     
do cnt = 1 to tjbs                                                             
   if job_msize.cnt < 500000 then                                             
         iterate                                                               
    cnt1 = cnt1 + 1                                                           
   DLINES.cnt1     = left(Job_name.cnt,10)  || left(Job_id.cnt,10) ,           
                ||  left(job_lct.cnt,10)  || left(job_flag.cnt,3) ,           
                ||  right(job_msize.cnt,10)                                   
end                                                                           
    say 'Total no of jobs with more than 500000 byte count'  cnt1             
    CALL SORT_DLINES                                                           
    "EXECIO * DISKW OUTFIL (STEM DLINES. FINIS"                               
    CALL CREATE_MSG                                                           
    "EXECIO * DISKW OUTFIL2 (STEM MSGL. FINIS"                                 
  DROP DLINES                                                                 
  DROP MSGL                                                                   
/*ADDRESS TSO "SE '"M2"',USER("USER.1"),LOGON" */                             
EXIT                                                                           
                                                                               
/* Sort the jobs based on First 4 bytes of the job name */                     
SORT_DLINES:                                                                   
"ALLOC FI(SYSOUT)   SYSOUT(X)"                                                 
"ALLOC FI(SYSIN)    NEW TRACKS SPACE(3 3)     RECFM(F B) LRECL(80)"           
"ALLOC FI(SORTIN)   NEW TRACKS SPACE(133 133) RECFM(F B) LRECL(133)"           
"ALLOC FI(SORTOUT)  NEW TRACKS SPACE(133 133) RECFM(F B) LRECL(133)"           
QUEUE " SORT FIELDS=(1,8,CH,A)"                                               
QUEUE " END"                                                                   
"EXECIO "QUEUED() "DISKW SYSIN   ( FINIS"                                     
"EXECIO * DISKW SORTIN  ( STEM  DLINES. FINIS"                                 
   DROP DLINES                                                                 
"CALL *(SORT)"                                                                 
"EXECIO * DISKR SORTOUT ( STEM DLINES. FINIS"                                 
"FREE  FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"                                       
SORT_DLINES_EXIT: RETURN                                                       
                                                                               
/* Send tso message to those users which are present in the Userfile */       
CREATE_MSG:                                                                   
                                                                               
LINE1 =  'USR1                              ************************************
**********'                                                                     
LINE2 =  'USR1                              ********PLEASE PURGE THE FOLLOWING J
OBS*******'                                                                     
LINE3 =  'USR1                                      '                           
MCNT = 0                                                                       
MCNT = 0                                                                       
CUR_USER = space                                                               
DO CNT = 1 TO CNT1                                                             
   temp_user = SUBSTR(DLINES.CNT,1,4) /* first 4 bytes of job name = username*/
   IF CUR_USER ¬= temp_user THEN                                               
     DO                                                                         
      if CHECK_USER()  then                                                     
         do                                                                     
           iterate                                                             
         end                                                                   
       if CUR_USER ¬= space then                                               
          do                                                                   
            MCNT = MCNT + 1                                                     
            MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"                   
          end                                                                   
      CUR_USER = temp_user                                                     
      MCNT = MCNT + 1                                                           
      MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"                         
      MCNT = MCNT + 1                                                           
      MSGL.MCNT = "SE '"LINE2"',USER("CUR_USER"),LOGON"                         
     END                                                                       
     LINE4 = LINE3||LEFT(substr(DLINES.cnt,1,20),38)                           
     MCNT = MCNT + 1                                                           
     MSGL.MCNT = "SE '"LINE4"',USER("CUR_USER"),LOGON"                         
   IF CNT = CNT1 THEN                                                           
     DO                                                                         
      MCNT = MCNT + 1                                                           
      MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"                         
     END                                                                       
END                                                                             
CREATE_MSG_EXIT: RETURN                                                         
                                                                               
CHECK_USER:                                                                     
 do usr = 1 to USERIDS.0                                                       
    if temp_user = userids.usr then                                             
      DO                                                                       
       return 0                                                               
      END                                                                     
 end                                                                           
CHECK_USER_EXIT: RETURN 1                                                     

The code looks slightly big, but that is all i have come up with, if any of you have a better solution, please let me know.
The Code is taking around 4 to 5 mins to scan through 1000 jobs
So, I am executing in batch using the jcl generated by the rexx code in the link which I have given it in my previous post.
The jcl is also slightly big, so I have not posted. Let me know if any one needs the jcl also.

Thanks,
Balu
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 09, 2009 7:38 pm
Reply with quote

Hi Balu,

Thank you for posting your solution icon_smile.gif

d
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top