We all have done it at one time or another. Our object library option in PDM was not what we thought it was, or our library list was messed up when we went to compile that new logical file. In many cases, we ended up with a job that did not complete normally, and we went on to correct the situation.
But what if the conditions were such that the job did complete normally? The end result would be that we created an "Outlaw Logical" file that resides in a different library from the physical file.
This condition is potentially dangerous for a number of reasons. For instance, error messages come up when a called program is looking for a logical file that is nowhere to be found in the library list. Another problem could be revealed during the save/restore process. If the physical file does not already reside on disk when the system attempts to restore the logical file, the system will give you an error message, and the logical file will not be restored.
What makes this situation alarming is that you may have an outlaw on your system and not even know it. It may be lurking around the next corner waiting to pounce upon some poor unsuspecting end user at the worst possible time.
The good news is that you can do something about it. Think of the utility in this article as your own Wyatt Earp or Matt Dillon. You can use it to sniff out those nasty outlaws and put them back where they belong.
Find Me Some Bad Guys
The Display Displaced Logical Files (DSPDISLF) command (1) may be run over a specific library, a library list, or all libraries on your system. The program will find all outlaw logical files in the libraries specified and bring them up in a subfile display (see 2).
The Display Displaced Logical Files (DSPDISLF) command (Figure 1) may be run over a specific library, a library list, or all libraries on your system. The program will find all outlaw logical files in the libraries specified and bring them up in a subfile display (see Figure 2).
The program DIS001RG (3) will display outlaw logical files, even if the physical files they are over are not in the libraries specified. If the physical file and logical file both meet the designated search criteria, you will see the record listed twice in the subfile (more on this later). 4 (page 94) contains the DDS for the display file DIS001DF.
The program DIS001RG (Figure 3) will display outlaw logical files, even if the physical files they are over are not in the libraries specified. If the physical file and logical file both meet the designated search criteria, you will see the record listed twice in the subfile (more on this later). Figure 4 (page 94) contains the DDS for the display file DIS001DF.
We'll Need a Good Scout
DIS001RG is a simple subfile display program over the system file QADBLDNC. This file is the dependency logical multiple format file over the QADBFDEP file found in library QSYS. The QADBLDNC file is used to define the relationship between all of the physical and logical files on your system.
The QADBLDNC logical file has two formats. One format, QDBFDEP, is keyed by library and physical file. The other format in the file is QDBNC2, which is keyed by library and dependent file. Our program uses both formats depending upon the option selected when running the command.
The command accepts one parameter?library name. Valid values are *ALL, *LIBL, or a library name. If the parameter entered is a library name, the EXIST subroutine in the RPG program will check to ensure the library does, in fact, exist.
The EXIST subroutine uses the QUSR-OBJD API and monitors for an error message. If the library does not exist, the SNDERR subroutine is called to use the QMHSNDPM API to send the error message back to the caller.
If the library does exist, a status message is sent back to the caller's screen stating that the search for outlaws is taking place. This is necessary because, if you take the option to search all libraries on the system, the program may chug away for a minute or two while it reads all records in the file. The program ran in less than one minute on a fully loaded E20 with over 7,000 files filling 4.7GB of DASD.
If the library list option was chosen when running the command, the LIBLST subroutine is executed. LIBLST uses the JOBI0700 format of the QUSRJOBI API to retrieve a variable that contains the library list. This variable is then loaded into the AR work array.
How we determine which libraries are system libraries and which are user production libraries can be confusing, but here goes. Let's start with a refresher course on library lists. A library list contains four types of entries in this order: system libraries, product libraries, current library (maximum one entry), and user libraries.
The system libraries begin in posi-tion 81, and each library entry is 11 characters. Since we want to ignore the system libraries, we use the variable SYS#, which contains the number of system libraries, multiplied by 11 (the size of each library entry), plus 81 to yield the starting position of the product libraries.
The number of product libraries is in PRD#; the number of current libraries is in CUR#; and the number of user libraries is in USR#. These libraries are loaded into array ALIB, and the first element of ALIB is loaded into the LIB field, so only files in the first library will be read the first time through the main loop.
Once the search libraries have been identified, the dependent file is read. Any record in which the physical file's library is different from the dependent file's library is written to the subfile. The subroutine GETCRT uses the OBJD0300 format of the QUSROBJD API to retrieve who created the file and when.
At end of file, if the library list is being searched, the next element of ALIB is used to start the main loop again. This will continue until all of the libraries in the list are searched, at which time the subfile is displayed.
Note that we read the QDBFDEP format (keyed by library and physical file) if the value *ALL or *LIBL is specified and the QDBNC2 format (keyed by library and dependent file) if a single library (or library list) is being searched. This ensures that logicals based on a file in another library will be included in the search along with physical files residing in the search library. Because both the physical and logical files could be encountered in this search, the outlaw logical could appear twice in the subfile.
The only problem we encountered while testing this utility is that occasionally the system file QADBLDNC doesn't track file dependencies properly. This only happens if the physical file and the dependent logical file were created into QTEMP and then moved to other libraries. Since this is apparently a problem with the operating system, we were unable to make this utility work correctly under these conditions. However, this would probably happen only rarely, if ever, so it shouldn't prevent you from making use of this utility.
Should We Hang 'em or
Shoot 'em?
The penalty for creating outlaw logical files can differ by shop, but this article has given you a posse for hunting them down. If you run the DSPDISLF command on a regular basis, you can hunt down the varmints and get them before they get you.
Doug Pence is the founder and Ron Hawkins is the research and development manager of Computer Processing Unlimited, Inc. in San Diego, California.
Reference
System Programmers Interface Reference (SC41-8223, CD-ROM QBKA8402).
Beware of the Outlaw Logical File
Figure 1: Command DSPDISLF
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/DSPDISLF) PGM(XXX/DIS001RG) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ CMD PROMPT('Display Displaced Logicals') PARM KWD(LIB) TYPE(*NAME) DFT(*ALL) SPCVAL((*ALL) + (*LIBL)) PROMPT('Library')Beware of the Outlaw Logical File
Figure 2: Output from the DSPDISLF Command
Beware of the Outlaw Logical File
Figure 3: RPG Program DIS001RG
*=============================================================== * To compile: * * CRTRPGPGM PGM(XXX/DIS001RG) SRCFILE(XXX/QRPGSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FDIS001DFCF E WORKSTN F RRN KSFILE SFLRCD FQADBLDNCIF E K DISK E AR 4096 1 E ALIB 50 10 IERROR IDS I B 1 40BYTPRV I B 5 80BYTAVA I 9 15 MSGID I 16 16 ERR### I 17 116 MSGDTA I DS I B 1 40RCVLEN I B 5 80MSGKEY I B 9 120MSGDLN I B 13 160MSGQNB IRCVVAR DS 4096 I B 1 40BYTTOT I B 5 80BYTAVL I B 65 680SYS# I B 69 720PRD# I B 73 760CUR# I B 77 800USR# IRCVVR1 DS 460 I 66 670WHENYR I 68 710WHENMD I 220 229 CRE8BY IFILLIB DS I 1 10 FLIB I 11 20 FSYS I 'No displaced logical-C CONER1 I ' files found in' I 'Searching for displa-C CONMS1 I 'ced logical files' C *ENTRY PLIST C PARM INLIB 10 C 'QCPFMSG' CAT 'QSYS':3 MSGF C Z-ADD116 BYTPRV C MOVE *OFF ERR C MOVE INLIB LIB 10 * Make sure library exists C LIB IFNE '*ALL' C LIB ANDNE'*LIBL' C EXSR EXIST C ENDIF C ERR IFEQ *OFF C Z-ADD50 MSGDLN C MOVELCONMS1 MDATA P C MOVEL'CPF9898' MSGID C MOVEL'*STATUS' MSGTYP C MOVEL'*EXT' MSGQ C Z-ADD0 MSGQNB C EXSR SNDERR C SELEC C LIB WHEQ '*ALL' C *LOVAL SETLLQDBFDEP C LIB WHEQ '*LIBL' C EXSR LIBLST C LIB SETLLQADBLDNC C OTHER C LIB SETLLQADBLDNC C ENDSL C *IN41 DOUEQ*ON C LIB IFEQ '*ALL' C LIB OREQ '*LIBL' C READ QDBFDEP 41 C ELSE C LIB READEQADBLDNC 41 C ENDIF C *IN41 IFEQ *OFF C DBFLIB IFNE DBFLDP C EXSR GETCRT C Z-ADD0 WHEN C MOVELWHENMD WHEN C MOVE WHENYR WHEN C ADD 1 RRN 40 C WRITESFLRCD C ENDIF C ELSE C INLIB IFEQ '*LIBL' C ADD 1 I C ALIB,I IFNE *BLANKS C MOVEAALIB,I LIB C LIB SETLLQADBLDNC C MOVE *OFF *IN41 C ENDIF C ENDIF C ENDIF C ENDDO * C RRN IFNE *ZEROS C MOVE *ON *IN21 C WRITEFKEYS C EXFMTSFLCTL C ELSE * No libraries found with displaced logical files C Z-ADD50 MSGDLN C MOVELCONER1 MDATA P C MDATA CAT LIB:1 MDATA C MOVEL'CPF9898' MSGID C MOVEL'*DIAG ' MSGTYP C MOVEL'* ' MSGQ C Z-ADD1 MSGQNB C EXSR SNDERR C ENDIF C ENDIF C MOVE *ON *INLR *=============================================================== C GETCRT BEGSR *=============================================================== * Get who created logical file and when C MOVELDBFFDP FILLIB 20 C MOVELDBFLDP FSYS C CALL 'QUSROBJD' C PARM RCVVR1 C PARM 460 RCVLEN C PARM 'OBJD0300'FILFMT 8 C PARM FILLIB C PARM '*FILE' OBJTYP 10 C PARM ERROR C ENDSR *=============================================================== C EXIST BEGSR *=============================================================== * Make sure requested library exists C MOVELLIB FILLIB 20 C MOVEL'QSYS' FSYS C CALL 'QUSROBJD' C PARM RCVVAR C PARM 5000 RCVLEN C PARM 'OBJD0100'FILFMT 8 C PARM FILLIB C PARM '*LIB' OBJTYP C PARM ERROR C MSGID IFNE *BLANKS C Z-ADD50 MSGDLN C MOVELLIB MDATA C MOVEL'*ESCAPE' MSGTYP C MOVEL'* ' MSGQ C Z-ADD1 MSGQNB C EXSR SNDERR C ENDIF C ENDSR *=============================================================== C SNDERR BEGSR *=============================================================== * Send error back to caller C CALL 'QMHSNDPM' C PARM MSGID C PARM MSGF 20 C PARM MDATA 50 C PARM MSGDLN C PARM MSGTYP 10 C PARM MSGQ 10 C PARM MSGQNB C PARM MSGKEY C PARM ERROR C MOVE *ON ERR 1 C ENDSR *=============================================================== C LIBLST BEGSR *=============================================================== * Get library list C CALL 'QUSRJOBI' C PARM RCVVAR C PARM 5000 RCVLEN C PARM 'JOBI0700'FILFMT 8 C PARM '*' JOBNAM 26 C PARM INTJOB 16 C MOVEARCVVAR AR,1 C SYS# MULT 11 I 40 C ADD 81 I C Z-ADD1 J 40 C DO PRD# C MOVEAAR,I ALIB,J C ADD 1 J C ADD 11 I C ENDDO C DO CUR# C MOVEAAR,I ALIB,J C ADD 1 J C ADD 11 I C ENDDO C DO USR# C MOVEAAR,I ALIB,J C ADD 1 J C ADD 11 I C ENDDO C MOVEAALIB,1 LIB C Z-ADD1 I C ENDSR *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
Beware of the Outlaw Logical File
Figure 4: Display File DIS001DF
*=============================================================== * To compile: * * CRTDSPF FILE(XXX/DIS001DF) SRCFILE(XXX/QDDSSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DSPSIZ(24 80 *DS3) A PRINT A CA03(03 'Exit') A CA12(12 'Cancel') A R SFLRCD SFL A DBFFIL 10A O 4 5 A DBFLIB 10A O 4 18 A DBFFDP 10A O 4 31 A DBFLDP 10A O 4 44 A CRE8BY 10A O 4 57 A WHEN 6Y 0O 4 70EDTCDE(Y) A R SFLCTL SFLCTL(SFLRCD) A SFLSIZ(0032) A SFLPAG(0016) A OVERLAY A 21 SFLDSP A SFLDSPCTL A 41 SFLEND(*MORE) A 1 25'Display Displaced' A DSPATR(HI) A 1 43'Logical Files' A DSPATR(HI) A 3 5'Physical' A DSPATR(HI) A 3 18'Library' A DSPATR(HI) A 3 31'Logical' A DSPATR(HI) A 3 44'Library' A DSPATR(HI) A 3 57'Created By' A DSPATR(HI) A 3 70'Created On' A DSPATR(HI) A R FKEYS A 22 6'F3=Exit' A COLOR(BLU) A 22 17'F12=Cancel' A COLOR(BLU) *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
LATEST COMMENTS
MC Press Online