Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Re-organizing files based on passed parms

Re-organizing files is not always an easy thing to do. Let this tip walk you through the process.

These two CL programs will accept a library name and a user defined 'threshhold' as a basis for reorganizing files within a library. The two parms are passed on the call statement.


/*** program REORGFILE to build outfile from DSPFFD and call program to reorg files */

 
PGM        PARM(&THRESHHOLD)                        
                                                                 
             DCL        VAR(&THRESHHOLD) TYPE(*DEC) LEN(15 5)    
             DCL        VAR(&PCT) TYPE(*DEC) LEN(15 5)           
             DCL        VAR(&TOTRECS) TYPE(*DEC) LEN(10)         
                                                                 
             DCLF       FILE(*LIBL/FILELIST)                     
                                                                 
                                                                 
 READLOOP:   RCVF                                                
                                                                 
 /*     MONITOR FOR EOF IN DRIVER FILE         */                
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(FINAL))        
                                                                       
/* IGNORE MEMBERS WITH ZERO RECORDS   */                               
                                                                       
             IF         COND(&MLNDTR *EQ 0) THEN(GOTO CMDLBL(READLOOP) 
                                                                       
/* CALCULATE PERCENTAGE OF DELETED RECORDS AND COMPARE TO THRESHHOLD */ 
                                                                       
             CHGVAR     VAR(&TOTRECS) VALUE(&MLNRCD + &MLNDTR)         
                                                                       
             CHGVAR     VAR(&PCT) VALUE((&MLNDTR / &TOTRECS) * 100)     
                                                   
                                                                       
             IF         COND(&PCT *LT &THRESHHOLD) THEN(GOTO +         
                          CMDLBL(READLOOP)) 
                           
             RGZPFM     FILE(&MLLIB/&MLFILE) MBR(&MLNAME)  
             MONMSG     MSGID(CPF0000)                     
                                                            
             GOTO       CMDLBL(READLOOP)                   
 FINAL:                                                    
             DLTF       FILE(FILELIST)                     
                                                            
             ENDPGM    

** When compiling the "REORG" program, a file must exist in your library list call FILELIST and be an outfile from a DSPFD. Once the programs have been compiled, this file may be deleted.

This was last published in August 2001

Dig Deeper on iSeries system performance and monitoring

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close