Reorganizing all files in a library

You Can View User Feedback To This Tip

These two programs allow the reorganization of all files in a selected library. One program specifies the library(s)while the other (after submission to batch) does the reorganizing. Since the files used are created in QTEMP the system cleans up after itself after the job is finished.

0002.00              PGM                                     Program to submit the Library for reorg.

0003.00         MONMSG MSGID(CPF0000)                                    
0003.02       SBMJOB     CMD(CALL PGM(qgpl/RGZLIBFCL) PARM('TSTSEC' +       
0003.03                     '*ALL')) JOBQ(QPGMR)                 
0001.00   /*  REORG ALL PHYSICAL FILES IN RGZLIBF IN QTEMP                      
0002.00              PGM        PARM(&LIB &FIL)                                 
0004.00              DCLF       FILE(QSYS/QAFDMBRL)                             
0005.00              DCL        VAR(&SLIB) TYPE(*CHAR) LEN(10)                  
0006.00              DCL        VAR(&MBR) TYPE(*CHAR) LEN(10)                   
0008.00              DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                   
0009.00              DCL        VAR(&FIL) TYPE(*CHAR) LEN(10)                   
0011.00              DCL        VAR(&ODLBNM) TYPE(*CHAR) LEN(10)                
0012.00              DCL        VAR(&ODOBNM) TYPE(*CHAR) LEN(10)                
0014.00              OVRDBF     FILE(QAFDMBRL) TOFILE(QTEMP/MBRS)               
0016.00              DSPFD      FILE(&LIB/&FIL) TYPE(*MBRLIST) +                
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7  
0017.00                           OUTPUT(*OUTFILE) FILEATR(*PF) +               
0018.00                           OUTFILE(QTEMP/MBRS)                           
0020.00  AGAIN:      RCVF       RCDFMT(QWHFDML) /* File from Display File +     
0021.00                           Description */                                
0023.00              MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF))           
0024.00              MONMSG     MSGID(CPF0001) EXEC(GOTO CMDLBL(EOF))           
0026.00              RGZPFM     FILE(&MLLIB/&MLFILE) MBR(*FIRST)                
0027.00              MONMSG     MSGID(CPF2981)                                  
0029.00              GOTO       CMDLBL(AGAIN)                                   
0030.00   /*                                                                    
0031.00  EOF:        ENDPGM                                                     
****************** End of data ***********************************   


The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


  • The program should reorganize the member name in the DSPFD outfile, rather than *FIRST. As it stands, it would repeatedly reorganize the *FIRST member of a multi-member file! Change the reorganize command to: RGZPFM FILE(&MLLIB/&MLFILE) MBR(&MLNAME). — Nick Hobson

This was first published in January 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.