If you've ever had to set up a test system on the same box as your 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 &lib dcl &type *char 001 dcl &lib *char 010 dcl &msgq *char 010 dcl &msg *char 512 dcl &blankmsg *char 512 dclf qafdmbr dltf qtemp/qafdmbr monmsg cpf0000 rtvjoba type(&type) /* Get message queue depending on whether this a batch or interactive job */ if (&type *eq '0') then(rtvjoba sbmmsgq(&msgq)) if (&type *eq '1') then(rtvjoba job(&msgq)) dspfd &lib/*all type(*mbr) output(*outfile) + outfile(qtemp/qafdmbr) fileatr(*lf) ovrdbf qafdmbr qtemp/qafdmbr rcvf: rcvf monmsg cpf0864 exec(goto endpgm) if (&lib *eq &mbbol) then(goto rcvf) /* if it makes it to this point, it is an error */ chgvar &msg &blankmsg chgvar &msg (&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 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 &lib /* check all pfs in a lib & make sure they don't have */ /* logical files in any other lib */ dclf qafdphy dcl type *char 01 dcl msgq *char 10 dcl lib *char 10 dltf qtemp/qadspdbr monmsg cpf0000 dltf qtemp/qafdphy monmsg cpf0000 rtvjoba type(&type) /* Get message queue depending on whether this a batch or interactive job */ if (&type *eq '0') then(rtvjoba sbmmsgq(&msgq)) if (&type *eq '1') then(rtvjoba job(&msgq)) /* Build a list of all physical files in a library */ dspfd &lib/*all type(*atr) output(*outfile) + outfile(qtemp/qafdphy) fileatr(*pf) ovrdbf qafdphy qtemp/qafdphy rcvf: rcvf monmsg cpf0864 exec(do) call pfcheck2 (&lib &msgq) goto endpgm enddo /* Only look at data files (Ignore source files) */ if cond(&phdtat *ne 'D') then(goto rcvf) /* Build file of all based on lfs */ dspdbr &phlib/&phfile output(*outfile) + outfile(qtemp/qadspdbr) outmbr(*first *add) goto 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 (&lib &msgq) dcl &lib *char 010 dcl &msgq *char 010 dcl &msg *char 512 dcl &blankmsg *char 512 dclf qadspdbr ovrdbf qadspdbr qtemp/qadspdbr rcvf: rcvf monmsg cpf0864 exec(goto endpgm) /* Only check logical files */ if (&whrefi *eq ' ') then(goto rcvf) if (&lib *eq &whreli) then(goto rcvf) /* If it makes it to this point, it is an error */ chgvar &msg &blankmsg chgvar &msg (&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 rcvf endpgm: endpgm /**************************************************************************/ Tim Granatir, Search400.com expert 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. |