165 pts.
 Command to track how many spool files users have
I have certain users who never clean out their spool files. Is there any command I can run which will tell me how many spool files a user has out there? I am currently on version V5R4 of the operating system

Software/Hardware used:
v5r4
ASKED: September 27, 2010  3:20 PM
UPDATED: September 29, 2010  12:15 AM

Answer Wiki:
One way to do this is to do do WRKSPLF &User output(*PRINT) Then do a CPYSPLF to a disk file Look at the data and determine how you want to use it. It may be as simple as get the record count of the file and subtract n (which would be determined my the number of records for page headings).
Last Wiki Answer Submitted:  September 28, 2010  2:10 pm  by  CharlieBrowne   32,945 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,945 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Is there any command I can run which will tell me how many spool files a user has out there?

No, not unless you have created one. For most systems, that would be fairly easy.

Tom

 108,360 pts.

 

An example program to retrieve the count of spooled files for a user:

pgm    ( +
         &pUser       +
       )

   dcl   &pUser       *char   10


   dcl   &User        *char   10
   dcl   &QOutQ       *char   20     value( '*ALL' )
   dcl   &Form        *char   10     value( '*ALL' )
   dcl   &UsrDta      *char   10     value( '*ALL' )

   dcl   &UsrSpc      *char   10     value( SLTSPLF )
   dcl   &UsrSpcLib   *char   10     value( QTEMP )

   dcl   &QUsrSpc     *char   20
   dcl   &us_hdr      *char  150

   dcl   &nbrlste     *dec  (  9 0 )
   dcl   &cNbrSplf    *char    6


   chgvar    &User            &pUser
   monmsg  ( mch3601 )  exec( do )
      rcvmsg      msgtype( *LAST ) rmv( *YES )
      monmsg    ( cpf0000 cpf9999 mch0000 )
      chgvar &User            '*CURRENT'
   enddo


   chgvar    &QUsrSpc       ( &UsrSpc *cat &UsrSpcLib )

/* Create a user space... */
   call        QUSCRTUS     ( +
                              &QUsrSpc     +
                              'SPLFLST   ' +
                              x'00001000'  +
                              X'00'        +
                              '*ALL      ' +
                              'Temp list splfs        ' +
                              '*YES      ' +
                              x'00000000'  +
                            )


/* List user's spooled files into the space... */
   call        QUSLSPL      ( +
                              &QUsrSpc     +
                              'SPLF0100'   +
                              &User        +
                              &QOutQ       +
                              &Form        +
                              &UsrDta      +
                            )


/* Retrieve the number of list entries from the space... */
   call        QUSRTVUS     ( +
                              &QUsrSpc     +
                              x'00000001'  +
                              x'00000096'  +
                              &us_hdr      +
                            )

/* A full space header was retrieved, but we only need this... */
   chgvar     &nbrlste       %bin( &us_hdr    133 4 )


   if ( &nbrlste *eq 0 )  do
      sndpgmmsg  msgid( CPF9898 ) msgf( QSYS/QCPFMSG ) +
                   msgdta( 'No spooled files found' )
   enddo
   else  do
      chgvar  &cNbrSplf          ( &nbrlste )
      sndpgmmsg  msgid( CPF9898 ) msgf( QSYS/QCPFMSG ) +
                   msgdta( &User *bcat 'has' *bcat &cNbrSplf *bcat +
                           'spooled files' )
   enddo


Clean_up:

   dltusrspc  &UsrSpcLib/&UsrSpc


   return

endpgm

Call it with a user profile name as a parm. If no parm is supplied, the program will default to ‘*CURRENT’.

Test it, modify it, do whatever you wish. Wrap it in a *CMD and set a return parm instead of a message. If you need info on the APIs, just search on their names in the Information Center.

Tom

 108,360 pts.