Tip

Hey! You've got your test file in my production library

Tim Granatir, Search400.com expert

If you've ever had to set up a test system on the same box as you production system, you have probably experienced one of the following situations with logical files:

  • A logical file built over a test system somehow makes it into a production library
  • A logical file built over a production library makes in into a test library
  • A programmer has a long forgotten logical built in a separate library

Especially in the case of the first two situations, those can cause some real problems and become a serious challenge to track down.

Below are a couple simple utilities that were built to identify just such problems. The first one is called LFCHECK. It makes sure that your logical files are built over the physical files in the same library. The second one is called PFCHECK1. It checks all of your physical data files in a library and makes sure that all of their logical files are built in the same library as the physical file. If your data setup requires that logical files reside in different libraries than your physical files, then these utilities can be easily modified to fit your requirements. You'll find the coding of these CLs simple and straightforward. The real benefit to these utilities is the aggravation they may save you down the road.

/**************************************************************************/
/* PGM LFCHECK – Make sure all logical files in a library are based on    */
/*               physical files in the same library                       */
/**************************************************************************/
             PGM        PARM(&LIB)                                            
             DCL        VAR(&TYPE) TYPE(*CHAR) LEN(1)                         
             DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                         
             DCL        VAR(&MSGQ) TYPE(*CHAR) LEN(10)                        
             DCL        VAR(&MSG) TYPE(*CHAR) LEN(512)                        
             DCL        VAR(&BLANKMSG) TYPE(*CHAR) LEN(512)                   
             DCLF       FILE(QAFDMBR)                                         
                                                                              
             DLTF       FILE(QTEMP/QAFDMBR)                                   
             MONMSG     MSGID(CPF0000)                                        
                                                                              
             RTVJOBA    TYPE(&TYPE)                                           
 /* Get message queue depending on whether this a batch or interactive job */ 
             IF         COND(&TYPE *EQ '0') THEN(RTVJOBA +                    
                          SBMMSGQ(&MSGQ))                                     
             IF         COND(&TYPE *EQ '1') THEN(RTVJOBA JOB(&MSGQ))          
                                                                              
             DSPFD      FILE(&LIB/*ALL) TYPE(*MBR) OUTPUT(*OUTFILE) +         
                          OUTFILE(QTEMP/QAFDMBR) FILEATR(*LF)                 
                                                                              
             OVRDBF     FILE(QAFDMBR) TOFILE(QTEMP/QAFDMBR)                   
                                                                              
 RCVF:                                                                        
             RCVF 
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))         
                                                                         
             IF         COND(&LIB *EQ &MBBOL) THEN(GOTO CMDLBL(RCVF))    
                                                                         
      /* IF IT MAKES IT TO THIS POINT, IT IS AN ERROR */                 
             CHGVAR     VAR(&MSG) VALUE(&BLANKMSG)                       
                                                                         
             CHGVAR     VAR(&MSG) VALUE(&MBFILE *BCAT 'in library' +     
                          *BCAT &MBLIB *BCAT 'is based on physical +     
                          file' *BCAT &MBBOF *BCAT 'in library' *BCAT +  
                          &MBBOL *TCAT '.')                              
             SNDPGMMSG  MSG(&MSG) TOMSGQ(&MSGQ)                          
                                                                         
             GOTO       CMDLBL(RCVF)                                     
 ENDPGM:                                                                 
             ENDPGM    


/**************************************************************************/
/* PGM PFCHECK1 – Build list a database relations list for all Physical   */
/*               data files in a library.  Then call program PFCHECK2     */
/*               to do the comparison.                                    */
/**************************************************************************/
             PGM        PARM(&LIB)                                           
             /* CHECK ALL PFS IN A LIB A& MAKE SURE THEY DONT HAVE  */       
             /* LOGICAL FILES IN ANY OTHER LIB                      */       
             DCLF       FILE(QAFDPHY)                                        
             DCL        VAR(&TYPE) TYPE(*CHAR) LEN(1)                        
             DCL        VAR(&MSGQ) TYPE(*CHAR) LEN(10)                       
             DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                        
                                                                             
             DLTF       FILE(QTEMP/QADSPDBR)                                 
             MONMSG     MSGID(CPF0000)                                       
                                                                             
             DLTF       FILE(QTEMP/QAFDPHY)                                  
             MONMSG     MSGID(CPF0000)                                       
                                                                             
             RTVJOBA    TYPE(&TYPE)                                          
 /* Get message queue depending on whether this a batch or interactive job */
             IF         COND(&TYPE *EQ '0') THEN(RTVJOBA +                   
                          SBMMSGQ(&MSGQ))                                    
             IF         COND(&TYPE *EQ '1') THEN(RTVJOBA JOB(&MSGQ))         
 /* Build a list of all physical files in a library */                                                                                                                                                                 
             DSPFD      FILE(&LIB/*ALL) TYPE(*ATR) OUTPUT(*OUTFILE) +        
                          OUTFILE(QTEMP/QAFDPHY) FILEATR(*PF)                
                                                                             
             OVRDBF     FILE(QAFDPHY) TOFILE(QTEMP/QAFDPHY)
  RCVF:                                                                  
              RCVF                                                       
              MONMSG     MSGID(CPF0864) EXEC(DO)                         
                CALL       PGM(PFCHECK2) PARM(&LIB &MSGQ)                
                GOTO       CMDLBL(ENDPGM)                                
              ENDDO                                                      
       /* Only look at data files (Ignore source files)       */                                                                                                
              IF         COND(&PHDTAT *NE 'D') THEN(GOTO CMDLBL(RCVF))   
                                                                         
       /* BUILD FILE OF ALL BASED ON LFS */                              
              DSPDBR     FILE(&PHLIB/&PHFILE) OUTPUT(*OUTFILE) +         
                           OUTFILE(QTEMP/QADSPDBR) OUTMBR(*FIRST *ADD)   
              GOTO       CMDLBL(RCVF)                                    
                                                                         
 ENDPGM:                                                                 
              ENDPGM  

/**************************************************************************/
/* PGM PFCHECK2– Check all physical data files in a library and find any  */
/*               logical files that do not reside in the same library     */
/**************************************************************************/
             PGM        PARM(&LIB &MSGQ)                               
             DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                  
             DCL        VAR(&MSGQ) TYPE(*CHAR) LEN(10)                 
             DCL        VAR(&MSG) TYPE(*CHAR) LEN(512)                 
             DCL        VAR(&BLANKMSG) TYPE(*CHAR) LEN(512)            
             DCLF       FILE(QADSPDBR)                                 
                                                                       
             OVRDBF     FILE(QADSPDBR) TOFILE(QTEMP/QADSPDBR)          
                                                                       
 RCVF:                                                                 
             RCVF                                                      
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))       
                                                                       
      /* ONLY CHECK LOGICAL FILES  */                                  
             IF         COND(&WHREFI *EQ '          ') THEN(GOTO +     
                          CMDLBL(RCVF))                                
                                                                       
             IF         COND(&LIB *EQ &WHRELI) THEN(GOTO CMDLBL(RCVF)) 
                                                                       
      /* IF IT MAKES IT TO THIS POINT, IT IS AN ERROR */               
             CHGVAR     VAR(&MSG) VALUE(&BLANKMSG)                     
                                                                       
             CHGVAR     VAR(&MSG) VALUE(&WHREFI *BCAT 'in library' +   
                          *BCAT &WHRELI *BCAT 'is based on physical +  
                          file' *BCAT &WHRFI *BCAT 'in library' *BCAT +  
                          &WHRLI *TCAT '.')                              
             SNDPGMMSG  MSG(&MSG) TOMSGQ(&MSGQ)                          
                                                                         
             GOTO       CMDLBL(RCVF)                                     
 ENDPGM:                                                                 
             ENDPGM                                                      
                                                                                                                                           

---------------------------
About the author: Tim is vice president of Technical Services at Interlink Technologies in Maumee, Ohio, where he serves as chief architect for their warehouse management system. He has worked in the banking, insurance, healthcare and distribution industries in various positions, including programmer/analyst, systems analyst and DP manager. Tim has worked on IBM midrange platforms since 1983.

==================================
MORE INFORMATION
==================================

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.