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

Three utilities to eliminate problems when you have a test system and production system on the same box.

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
==================================

  • Securing objects in a test system
    A user is creating a test environment that mirrors one of the production 400's. In the testing environment, a base copy of every object must be contained in a protected area of the system. This will then be used as a form of "baseline" to continuously create test subsets on the fly. Many of the objects on the production system are restricted through the use of auth lists. He asks, "Once we migrate all necessary objects to the test machine what will be the impact on the use of these objects if the affiliated authorization lists are not present?" Security expert Dan Riehl responds.
  • Testing a logical from within a CL program
    Is there a way to test a logical from within a CL program to see if it is currently being rebuilt? Site expert Pascal Jacquemain explains one way to do it.
  • Using CHGPF to handle file changes with ease
    Follow the steps detailed in this tip when the structure of a physical file changes and you need to recompile.

This was first published in October 2002

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close