Article

David Anderson -- Database relations and file usage code

   
   To create report of file usage:

****  Command  XREF
                                                                        
 CMD        PROMPT('EXECUTES CMD DCPGMRFCL.*LIBL')          
 PARM       KWD(FILE) TYPE(*CHAR) LEN(11) PROMPT('FILE +    
            NAME:') /* THE FILE YOU WISH TO CROSS +       
            REFERENCE*/                                   
 PARM       KWD(LIB) TYPE(*CHAR) LEN(10) DFT(*LIBL) +       
            PROMPT('LIBRARY:') /* THIS IS THE LIB +       
            THAT HOLDS THE FILE.  */                      
 PARM       KWD(RUNIN) TYPE(*CHAR) LEN(5) RSTD(*YES) +      
            DFT(BATCH) VALUES(BATCH INTER) +              
            PROMPT('RUN IN:') /* BATCH OR INTERACTIVE */  


****** CLP  DCPGMRCL

PGM        PARM(&FILE &LIB)                            
                                                       
DCL        VAR(&FILE) TYPE(*CHAR) LEN(11)              
DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)               
                                                       
IF         COND(&LIB = ' ') THEN(CHGVAR VAR(&LIB) +    
             VALUE('*LIBL'))                           
                                                       
DLTF       FILE(QTEMP/DBRLF2)                          
MONMSG     MSGID(CPF0000)                              
DLTF       FILE(QTEMP/DBRPF)                           
MONMSG     MSGID(CPF0000)                              
                                                       
CRTDUPOBJ  OBJ(DBRPF) FROMLIB(EM400) OBJTYPE(*FILE) +  
             TOLIB(QTEMP)                              
CRTLF      FILE(QTEMP/DBRLF2) SRCFILE(EM400/QDDSSRC)   
DLTSPLF    FILE(DBRLF2)                                
                                                       
DLTF       FILE(QTEMP/PGMXREF)                         
MONMSG     MSGID(CPF0000)                              
                                                       
CRTDUPOBJ  OBJ(PGMXREF) FROMLIB(EM400) OBJTYPE(*FILE) +
             TOLIB(QTEMP)                              
                                                       
OVRPRTF    FILE(QSYSPRT) OUTQ(HP5OO) FORMTYPE('0088') +
             HOLD(*YES)                                
                                                       
CALL       PGM(DCPGMRF) PARM(&FILE &LIB)               
                                                       
DLTF       FILE(QTEMP/DBRLF2)                          
MONMSG     MSGID(CPF0000)                              
DLTF       FILE(QTEMP/DBRPF)                           
MONMSG     MSGID(CPF0000)        
DLTF       FILE(QTEMP/PGMXREF)   
MONMSG     MSGID(CPF0000)        
ENDPGM


****** RPGLE  DCPGMRF

FPGMREFLF3 IF   E           K DISK                            
FDBRLF2    IF   E           K DISK                            
FMBRLISTLF1IF   E           K DISK                            
FPGMXREF   IF A E           K DISK                            
FQSYSPRT   O    F  132        PRINTER OFLIND(*INOF)           
D ARA             S             10    DIM(9) CTDATA PERRCD(1) 
D UPD             S              6  0 DIM(3)                  
D INP             S              6  0 DIM(3)                  
D UNK             S              6  0 DIM(3)                  
D                 DS                                          
D  WHLIB                  1     10                            
D   TESTLIB               1      1                            
D                 DS                                          
D  WHFNAM                 1     11                            
D  TEST1                  1      1                            
D                 DS                                          
D  NAMEDS                 1     11                              
D  TEST2                  1      1                              
D     NAME10              1     10                              
D*                                                              
D PROGDS         SDS                                            
D  $USER                254    263                              
C*                                                              
C     KEYXPRG       KLIST                                       
C                   KFLD                    NAME10              
C                   KFLD                    WHPNAM              
C*                                                              
C     *ENTRY        PLIST                                       
C                   PARM                    NAME             11 
C                   PARM                    PLIB             10 
C                   MOVE      *BLANKS       NAMEDS              
C                   MOVEL     NAME          NAMEDS                
C                   MOVEL     NAME10        KNAME            10   
C*                                                                
C     *IN(99)       IFEQ      '0'                                 
C                   MOVE      '1'           *IN(99)               
C                   MOVE      UDATE         DATE              6 0 
C                   TIME                    HHMMSS            6 0 
C                   Z-ADD     99            LINCNT                
C                   Z-ADD     0             TOTPRG            6 0 
C                   Z-ADD     0             TOTUPD            6 0 
C                   Z-ADD     0             TOTINP            6 0 
C                   Z-ADD     0             TOTUNK            6 0 
C                   CALL      'DSPDBRCL'                          
C                   PARM                    NAME10                
C                   PARM                    PLIB                  
C                   END                                           
C*                                                                     
C     NAMEDS        SETLL     PGMREFLF3                          90    
C     NAMEDS        READE     QWHDRPPR                               90
C                   DOW       *IN(90) = '0'                            
C                   EXSR      FOUNDSR                                  
C     NAMEDS        READE     QWHDRPPR                               90
C                   ENDDO                                              
C*                                                                     
C     *LOVAL        SETLL     DBRLF2                             89    
C     KNAME         READE     QWHDRDBR                               89
C     *IN(89)       DOWEQ     '0'                                      
C*                                                                     
C                   IF        WHREFI <> '*NONE'                        
C                             AND WHREFI > ' '                         
C                   MOVE      *BLANKS       NAMEDS                     
C                   MOVEL     WHREFI        NAMEDS                      
C     NAMEDS        SETLL     PGMREFLF3                          90     
C     NAMEDS        READE     QWHDRPPR                               90 
C                   DOW       *IN(90) = '0'                             
C                   EXSR      FOUNDSR                                   
C     NAMEDS        READE     QWHDRPPR                               90 
C                   ENDDO                                               
C                   ENDIF                                               
C*                                                                      
C     KNAME         READE     QWHDRDBR                               89 
C                   ENDDO                                               
C*
C                   SETON                                        LR     
C                   RETURN                                              
C**********************************************************************
C* FOUNDSR - FILE REFERENCED.                                         *
C**********************************************************************
C*                                                                    *
C     FOUNDSR       BEGSR                                              
C*                                                                     
C     WHLIB         IFEQ      *****  Eliminate test libraries here ********
C                   ELSE                                             
C*                                                                   
C                   Z-ADD     0             ARRAY            11 0    
C*                                                                   
C* COUNT PROGRAM ONCE PER FILE NAME.                                 
C     KEYXPRG       CHAIN     PGMXREF                            92  
C                   IF        *IN(92) = '1'                          
C                   MOVEL     NAME10        PGMXFILE                 
C                   MOVEL     WHPNAM        PGMXPRG                  
C                   WRITE     RPGMXREF                               
C*                                                                   
C     LINCNT        IFGE      60                                       
C                   EXCEPT    HDG01                                    
C                   Z-ADD     10            LINCNT            2 0      
C                   EXCEPT    HDG02                                    
C                   ADD       2             LINCNT                     
C                   MOVEL     NAMEDS        HLDNAM           11        
C                   END                                                
C*                                                                     
C     HLDNAM        IFNE      NAMEDS                                   
C                   MOVEL     NAMEDS        HLDNAM           11        
C                   EXCEPT    HDG02                                    
C                   ADD       2             LINCNT                     
C                   END                                                
C*                                                                     
C     LINCNT        IFGE      60                                       
C                   EXCEPT    HDG01                                    
C                   Z-ADD     10            LINCNT            2 0      
C                   EXCEPT    HDG02                                 
C                   ADD       2             LINCNT                  
C                   MOVEL     NAMEDS        HLDNAM           11     
C                   END                                             
C*                                                                  
C                   ADD       1             TOTPRG                  
C*                                                                  
C     WHPNAM        CHAIN     MBRLISTLF1                         93 
C                   IF        *IN(93) = '1'                         
C                   Z-ADD     0             MLNRCD                  
C                   MOVE      *BLANKS       MLUDAT                  
C                   ENDIF                                           
C*                                                                  
C     WHFUSG        IFGT      0                                     
C     WHFUSG        IFLT      8                                     
C                   Z-ADD     WHFUSG        X                 1 0   
C                   IF        WHFUSG = 1           
C                   ADD       1             TOTINP 
C                   IF        MLNRCD < 501         
C                   ADD       1             INP(1) 
C                   ELSE                           
C                   IF        MLNRCD < 1001        
C                   ADD       1             INP(2) 
C                   ELSE                           
C                   ADD       1             INP(3) 
C                   ENDIF                          
C                   ENDIF                          
C                   ELSE                           
C                   ADD       1             TOTUPD 
C                   IF        MLNRCD < 501         
C                   ADD       1             UPD(1) 
C                   ELSE                           
C                   IF        MLNRCD < 1001        
C                   ADD       1             UPD(2) 
C                   ELSE                           
C                   ADD       1             UPD(3) 
C                   ENDIF                          
C                   ENDIF                          
C                   ENDIF                          
C                   ELSE                           
C                   IF        MLNRCD < 501         
C                   ADD       1             UNK(1) 
C                   ELSE                           
C                   IF        MLNRCD < 1001        
C                   ADD       1             UNK(2) 
C                   ELSE                           
C                   ADD       1             UNK(3) 
C                   ENDIF                          
C                   ENDIF                          
C                   Z-ADD     8             X      
C                   ADD       1             TOTUNK    
C                   END                               
C                   ELSE                              
C                   IF        MLNRCD < 501            
C                   ADD       1             UNK(1)    
C                   ELSE                              
C                   IF        MLNRCD < 1001           
C                   ADD       1             UNK(2)    
C                   ELSE                              
C                   ADD       1             UNK(3)    
C                   ENDIF                             
C                   ENDIF                             
C                   Z-ADD     9             X         
C                   ADD       1             TOTUNK    
C                   END                               
C                   EXCEPT    DTL01                   
C                   ADD       1             LINCNT    
C                   END                                        
C*                                                             
C                   END                                        
CSR                 ENDSR                                      
C*                                                             
C**************************************************************
C*                                                             
OQSYSPRT   E            HDG01          1 06                    
O                                           13 'EM400/DCPGMRF' 
O                       $USER               38                 
O                                           62 'WHERE FILES'   
O                                           73 'REFERENCED'    
O                                          105 'PAGE'          
O                       PAGE          Z    110                 
O          E            HDG01          1                       
O                       DATE          Y      9                 
O                       HHMMSS              21 '  :  :  '        
O          E            HDG01       1                            
O                                           12 'PROGRAM REF'     
O                                           20 'USAGE'           
O                                           38 'PROGRAM'         
O                                           52 'LIBRARY'         
O                                           76 'TEXT DESCRIPTION'
O                                          123 'RECORDS'         
O                                          131 'USED'            
O          E            HDG02       1  1                         
O                       NAMEDS              12                   
O          E            DTL01       1                            
O                       ARA(X)              26                   
O                       WHPNAM              42                   
O                       WHLIB               56                   
O                       WHTEXT             110                   
O                       MLNRCD        Z    123                   
O                       MLUDAT             132  
**  ARA           
INPUT             
OUTPUT            
IN/OUTPUT         
UPDATE            
IN/UPDATE         
OUT/UPDATE        
IN/OUT/UPD        
NOT GIVEN         
NOT KNOWN    

********** Sample Report   ************

EM400/DCPGMRF               DAVID                  WHERE FILES REFERENCED      
  1/13/03    11:21:53                                                          
 PROGRAM REF   USAGE           PROGRAM       LIBRARY        TEXT DESCRIPTION   
 ORDR                                                                          
                INPUT           ADVCHK        BMESETL       Void/Update Advanc 
                IN/UPDATE       AGTBILLRP     OISPGM        Edit Agent billing 
                INPUT           AGTORDRSWP    OISPGM        CALLED FROM AGTTRA 
                INPUT           AGTSPAYRP     OISPGM        AGENT TRANSFER PRO
                IN/OUTPUT       AGTTRANRP     OISPGM        Edit Agent order f
                INPUT           ARORDER       EM400         Order listing by d
                NOT GIVEN       ARORDERCL2    EM400         Order list by date
                NOT GIVEN       ARORDERCL2    EM400         Order list by date
     
  
 
Related Topics: iSeries skills, VIEW ALL TOPICS

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: