Problem solve Get help with specific problems with your technologies, process and projects.

Identifying and removing logical files

Identifying and removing logical files

Is there a way to identify and remove all logical files from a library without doing individual removes? Could it be done programmatically?
There are several easy ways to do this.

I'll list the two that I consider to be the easiest for what you are trying to do -- one of these methods doesn't require programming and one does.

Without programming: You can use PDM WRKOBJPDM LIB(MYLIB) OBJTYPE(*FILE) OBJATR(LF). You can use an existion option (4 if you want to delete) on the first item and F13 to repeat to the end of the list.

With Programming: Write a small CL program to read through the list and do any processing. In this example, I used an output file for the DSPOBJD command, but depending on your needs, you could also use output files based on DSPFD, DSPDBR, etc. You'd just have to change the declared file and the variable names.

0001.00              PGM                                                    
0002.00              DCLF       FILE(QADSPOBJ)                              
0003.00              DSPOBJD    OBJ(MYLIB/*ALL) OBJTYPE(*FILE) +            
0004.00                           OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ)  
0005.00              OVRDBF     FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ)       
0006.00  RCVF:                                                             
0007.00              RCVF                                                   
0008.00              MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))    
0009.00              IF         COND(&ODOBAT *EQ 'LF') THEN(DO)             
0009.01                /* DO PROCESSING */                                  
0010.00              ENDDO                                                  
0011.00              GOTO       CMDLBL(RCVF)                                
0012.00  ENDPGM:                                                            
0013.00              ENDPGM        


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.

Dig Deeper on RPG iSeries programming