Q
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        

==================================
MORE INFORMATION ON THIS TOPIC
==================================

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

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

2 comments

Send me notifications when other members comment.

Please create a username to comment.

We have a dbr over two physical files name Q_AT000009.   It does not have a library associated with it, and I cannot access it to see it or get rid of it.
Cancel
Shar Files Dependent On Specified File                                    
   Dependent File         Library       Dependency   JREF    Constraint
       Q_AT000009                       Data            1             
       VPORFRL2           BWIDATA       Data                          
       VPORFRL1           BWIDATA       Data                            
Cancel

-ADS BY GOOGLE

SearchDataCenter

Close