Solved

Spool Entries

Posted on 2006-10-27
5
489 Views
Last Modified: 2012-05-05
Hello everyone,

I work for one of those companys that has the habit of keeping every spool file ever created for any reason on the system for all time.

I want to write some routines to pull off spooled data that is older than a specified date.  I know pretty much what to do as far as my application goes but here is my question.

What system files contain spool info?  I need a list of spool file number/Job/date etc. for all spool files on the system.  WRKSPLF will not let me direct output to a database file, which would be really nice.

Any information on how or where to accumilate this info would be appreciated.

Thanks
0
Comment
Question by:tcfrey
5 Comments
 
LVL 13

Accepted Solution

by:
_b_h earned 500 total points
ID: 17821589
Hi, tcfrey

The best way is to use the spooled file apis. The following program deletes splfs older than a given number of days in a given output queue. It needs some polishing, and of course testing, but it is basically functional and is a good starting point for you. If the program is named DLTSPLF, it is called:
call dltsplf (qezjoblog qusrsys x'00003f')  
which would delete splfs over three days old in qezjoblog

The source:
PGM ( &OUTQ  &OUTQLIB &DAYS)
DCL  &OUTQ      *CHAR   10  
DCL  &OUTQLIB   *CHAR   10  
DCL  &DAYS      *DEC  (5 0)
DCL  &OUTQQUAL  *CHAR   20  
DCL  &QDATE     *CHAR    6  
DCL  &QDATEJUL  *CHAR    5  
DCL  &QDATEJUY  *CHAR    2  
DCL  &QDATEJUYN *DEC  (2 0)
DCL  &QDATEJUD  *CHAR    3  
DCL  &QDATEJUDN *DEC  (3 0)
DCL  &QDATEYMD  *CHAR    8  
DCL  &KEEPCYMD  *CHAR    7  
DCL  &KEEPJUL   *CHAR    5  
DCL  &KEEPJULY  *CHAR    2  
DCL  &KEEPJULYN *DEC  (2 0)
DCL  &KEEPJULD  *CHAR    3  
DCL  &KEEPJULDN *DEC  (3 0)
DCL  &SP_JOB    *CHAR   10  
DCL  &SP_USER   *CHAR   10                              
DCL  &SP_NBR    *CHAR    6                              
DCL  &SP_OPNDAT *CHAR    7                              
DCL  &SP_PRTF   *CHAR   10                              
DCL  &SP_NBRBIN *CHAR    4                              
DCL  &SP_NBRDEC *DEC  (8 0)                              
DCL  &SP_NBRCHAR     *CHAR    8                          
DCL  &SP_JOBQUAL     *CHAR   26                          
DCL  &SP_USRDTA      *CHAR   10                          
DCL  &SP_TOTPAGD     *DEC   (8 0)                        
DCL  &SP_TOTPAGB     *CHAR     4                        
DCL  &SP_BUFSIZD     *DEC   (8 0)                        
DCL  &SP_BUFSIZB     *CHAR     4                        
DCL  &SP_NUMBUFD     *DEC   (8 0)                        
DCL  &SP_NUMBUFB     *CHAR     4                        
DCL &USRSPCQ   *CHAR  20  VALUE('@WRKOUTQ  QTEMP     ')  
DCL &USRSPC    *CHAR  10                                
DCL &USRSPCL   *CHAR  10                                
DCL &NBRENT    *DEC  (8 0)                              
DCL &BIN4      *CHAR   4                                
DCL &ENTLENB   *CHAR   4                                              
DCL &ENTLEN    *DEC  (8 0)                                            
DCL &POINTER   *DEC  (8 0)                                            
DCL &ENTRY     *CHAR  82                                              
DCL &INTJOB    *CHAR  16                                              
DCL &INTSPLF   *CHAR  16                                              
DCL &NEG1BIN   *CHAR   4                                              
DCL &SPLA31    *CHAR 3301                                              
DCL &SPLA42    *CHAR 3772                                              
DCL &SPLALEND  *DEC  (8 0)                                            
DCL &SPLALENB  *CHAR   4                                              
DCL &SPACEDATA *CHAR  14                                              
DCL &ERRCODE   *CHAR   4                                              
DCL  &ENDUSBIN  *CHAR    4                                            
DCL  &ENDUSDEC  *DEC  (8 0)                                            
/* CALCULATE THE YMD RETENTION DATE */                                
             RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&QDATE)                  
             CVTDAT     DATE(&QDATE) TOVAR(&QDATEJUL) FROMFMT(*JOB) +  
                          TOFMT(*JUL) TOSEP(*NONE)                    
             CHGVAR  &QDATEJUY %SST(&QDATEJUL 1 2)                    
             CHGVAR  &QDATEJUYN &QDATEJUY                          
             CHGVAR  &QDATEJUD %SST(&QDATEJUL 3 3)                
             CHGVAR  &QDATEJUDN &QDATEJUD                          
             CHGVAR  &KEEPJULDN (&QDATEJUDN - &DAYS)              
             CHGVAR  &KEEPJULYN &QDATEJUYN                        
NEXTYEAR:                                                          
             IF (&KEEPJULDN < 1) THEN(DO)                          
                CHGVAR &KEEPJULDN (&KEEPJULDN + 365)              
                CHGVAR &KEEPJULYN (&KEEPJULYN - 1  )              
                GOTO NEXTYEAR                                      
                ENDDO                                              
             CHGVAR &KEEPJULY  &KEEPJULYN                          
             CHGVAR &KEEPJULD  &KEEPJULDN                          
             CHGVAR &KEEPJUL  (&KEEPJULY || &KEEPJULD)            
             CVTDAT     DATE(&KEEPJUL) TOVAR(&KEEPCYMD) +          
                          FROMFMT(*JUL) TOFMT(*CYMD) TOSEP(*NONE)  
             SNDPGMMSG ('RETAIN DATE: ' || &KEEPCYMD)              
/* CHECK IF OUTQ EXISTS  */                                        
             CHKOBJ     OBJ(&OUTQLIB/&OUTQ) OBJTYPE(*OUTQ)        
             MONMSG (CPF9800) EXEC(DO)                            
                SNDPGMMSG (&OUTQ *BCAT 'NOT FOUND IN ' || &OUTQLIB)        
                GOTO ENDPGM                                                
                ENDDO                                                      
/* CREATE THE USER SPACE FOR THE LIST OF SPLFS IN THE OUTQ */              
CREATEUS:                                                                  
             CHGVAR   &USRSPC   %SST(&USRSPCQ  1 10)                      
             CHGVAR   &USRSPCL  %SST(&USRSPCQ 11 10)                      
             DLTUSRSPC &USRSPCL/&USRSPC                                    
             MONMSG (CPF2100)                                              
             CHGVAR  &OUTQQUAL  (&OUTQ || &OUTQLIB )                      
             CALL       PGM(QUSCRTUS) PARM(&USRSPCQ '          ' +        
               X'00010000' ' ' '*ALL      ' 'LIST OF SPLFS IN OUTQ')      
/* GET LIST OF SPLFS     */                                                
             CALL QUSLSPL (&USRSPCQ 'SPLF0100' '*ALL      ' &OUTQQUAL +    
                          '*ALL      ' '*ALL      ')                      
/* GET NUMBER OF ENTRIES */                                                
             CALL QUSRTVUS ( &USRSPCQ X'00000085' X'00000004' &BIN4)      
             CHGVAR &NBRENT %BINARY(&BIN4)                                
             IF (&NBRENT = 0 ) THEN(GOTO ENDPGM)                          
/* GET LIST ENTRY LENGTH AND OFFSET */                                    
             CALL QUSRTVUS ( &USRSPCQ X'00000089' X'00000004' &ENTLENB)  
             CHGVAR &ENTLEN   %BINARY(&ENTLENB)                          
             CALL QUSRTVUS ( &USRSPCQ X'0000007D' X'00000004' &BIN4)      
             CHGVAR &POINTER  %BINARY(&BIN4)                              
             CHGVAR &POINTER ( &POINTER + 1)                              
             CHGVAR %BINARY(&NEG1BIN)  -1                                
             CHGVAR &SPLALEND 3772  /*RELEASE SPECIFIC CODE */            
             CHGVAR %BINARY(&SPLALENB) (&SPLALEND)                        
NEXTSPLF:                                                                
             CHGVAR %BINARY(&BIN4) &POINTER                              
             CALL QUSRTVUS ( &USRSPCQ &BIN4 &ENTLENB &ENTRY)              
             CHGVAR &INTJOB  (%SST(&ENTRY 51 16))                        
             CHGVAR &INTSPLF (%SST(&ENTRY 67 16))                        
             CALL QUSRSPLA (&SPLA42 &SPLALENB   'SPLA0200' +              
                           '*INT                      ' &INTJOB &INTSPLF +
                           '*INT      '  &NEG1BIN)                        
             /*ADD MONITOR MESSAGE IF SPLF LONGER EXISTS */              
             /* SET UP TEXT DESCRIPTION FOR ARCHIVE USER SPACE */        
             CHGVAR &SP_PRTF    %SST(&SPLA42  75  10)                    
             CHGVAR &SP_NBRBIN  %SST(&SPLA42  85   4)                    
             CHGVAR &SP_NBRDEC  %BINARY(&SP_NBRBIN)                            
             CHGVAR &SP_NBRCHAR  &SP_NBRDEC                                    
             CHGVAR &SP_JOB     %SST(&SPLA42  49  10)                          
             CHGVAR &SP_USER    %SST(&SPLA42  59  10)                          
             CHGVAR &SP_NBR     %SST(&SPLA42  69   6)                          
             CHGVAR &SP_USRDTA  %SST(&SPLA42  99  10)                          
             CHGVAR &SP_OPNDAT  %SST(&SPLA42 211   7)                          
             IF (&SP_OPNDAT *LT &KEEPCYMD) THEN(DO)                            
                DLTSPLF    FILE(&SP_PRTF) JOB(&SP_NBR/&SP_USER/&SP_JOB) +      
                          SPLNBR(&SP_NBRCHAR)                                  
                SNDPGMMSG ('DELETED: ' || &SP_OPNDAT *BCAT &SP_PRTF *BCAT   +  
                   &SP_JOB *BCAT &SP_USER *BCAT &SP_NBR *BCAT &SP_NBRCHAR)    
                ENDDO                                                          
             IF ( &NBRENT > 1) THEN(DO)                                        
                CHGVAR &NBRENT  ( &NBRENT - 1)                                
                CHGVAR &POINTER ( &POINTER + &ENTLEN )                        
                GOTO NEXTSPLF                                                  
                ENDDO                                                          
ENDPGM:                                                                        
             ENDPGM                                                            

You could drive this program from a CL that calls it with output queues and retention days.
If you have any questions, please post back!
Barry
0
 
LVL 27

Expert Comment

by:tliotta
ID: 17824433
Minor note...

I expect Barry's program contains enough to do the job, so I don't need to comment there.

But, the basic question -- "What system files contain spool info?" -- leads to risky issues.

For good reason, the answer is "None."

Spooled file info isn't kept in files, at least not ones that we can make any good use of. Nor are they files that should even be opened for READ in any program outside of the spooling subsystem itself. Any access to spooled file info needs to be through the approved interfaces, either commands or the appropriate APIs. (Barry's program uses some of both.)

The "files" are not intended to be under DB2 control. Pointers and locks can be messed up if you use DB2 (or its APIs) to open them. Under earlier releases of OS/400, the content can be corrupted easily and your spooled files can be rendered effectively irretrievable. You didn't say what version you're running, though I don't know what version/release is tamper-proof in spooling anyway (if any).

Best is simply to avoid accessing the spaces other than through the interfaces designed for it.

Tom
0
 
LVL 14

Expert Comment

by:daveslater
ID: 17826318
Hi
i dowloaded a utility, mngsplf that allows you to delete, move, etc.. spool files based on various criteria including spacific users, outputq's, date & time, userdata.
If you are interested I can post set up a texfile on my website.

Dave
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
A procedure for exporting installed hotfix details of remote computers using powershell
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now