Problem solve Get help with specific problems with your technologies, process and projects.

Utility helps you get information about logical files faster, easier

Search400.com expert Tim Granatir provides a utility that allows you to just look at the source member of a logical file and get information about that file immediately.






Tim Granatir

When you're building new programs, you try to find files that are ordered or keyed a certain way. This lists the important information on the object text. For instance, if you find a file that is keyed the way you want but it has specific select/omit criteria, you may or may not be able to use that view of the data.

There are utilities out there that can help you get that information. The problem, however, is you have to stop and run those utilities to get it. In addition, the information those utilities provide is temporary. If you forget what you're looking for, you have to run the utilities and look up the information again.

It doesn't have to be that way. With my utility you can just look at the source member of the object or a logical file and get the information immediately. I also like this approach because as long as it runs after the logical is created or modified, it ensures that the text on the file is accurate and consistent. This will change the source member text and the object text to reflect if the file has the following:

  • A unique access path
  • Any selects or omits
  • The Physical file it is based on
  • The keys to the file

Example: Say an object has a text such as the following:

*YN: MYPF LF by-LASTNAME,FIRSTNAME

That text would mean the file is keyed UNIQUE, there are no Select/Omits, it is based on physical file MYPF, and the key fields are LASTNAME and FISRTNAME. If there are more keys than will fit on the text line, this program will put on as many as it can and denote that there are more by putting "…." at the end of the text.

This program assumes the logical file is compiled and that the source is QDDSSRC and resides in the same library as the object. I usually like to run this as a user-defined option in PDM where the user-defined option (F16 from PDM) would look like this: call fixlftext PARM(&N &L).

PGM          PARM(&FILE &LIB)                            
             DCLF       FILE(QAFDACCP)                              
             DCL        VAR(&TEXT) TYPE(*CHAR) LEN(50)              
             DCL        VAR(&FILE) TYPE(*CHAR) LEN(10)              
             DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)               
             DCL        VAR(&FILELIB) TYPE(*CHAR) LEN(10)           
             DCL        VAR(&FLDSIZE) TYPE(*DEC) LEN(3)             
             DCL        VAR(&TXTSIZE) TYPE(*DEC) LEN(3)             
             DCL        VAR(&COUNT) TYPE(*DEC) LEN(3)               
                                                                    
                                                                    
             CHGVAR     VAR(&FILELIB) VALUE(&LIB)                   
                                                                    
             DSPFD      FILE(&FILELIB/&FILE) TYPE(*ACCPTH) +        
                          OUTPUT(*OUTFILE) OUTFILE(QTEMP/QAFDACCP) +
                          OUTMBR(*FIRST *REPLACE)                   
             OVRDBF     FILE(QAFDACCP) TOFILE(QTEMP/QAFDACCP)       
  READ:                                                             
             RCVF                                                   
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(PROCESS))   

   /* DONT DO JOIN LF OR FILES BUILT OVER MORE THAN 1 PHYSICAL */     
   /* OR IF THIS IS NOT A LOGICAL FILE                         */     
             IF         COND(&APJOIN *EQ 'Y' *OR &APNSCO *GT 1 *OR +  
                          &APFTYP *NE 'L') THEN(GOTO CMDLBL(ENDPGM))  
                                                                      
   /* IF IN ARRIVAL SEQUENCE, THEN SET UNIQUE KEY FLAG TO (N)O */     
             IF         COND(&APNKYF *EQ 0) THEN(DO)                  
               CHGVAR     VAR(&APUNIQ) VALUE('N')                     
             ENDDO                                                    
                                                                      
   /* BUILD INITIAL TEXT RIGHT AFTER FIRST READ               */      
             IF         COND(&APKEYN *LE 1) THEN(CHGVAR VAR(&TEXT) +  
                          VALUE('*' *TCAT &APUNIQ *TCAT &APSELO +     
                          *TCAT ':' *BCAT &APBOF *BCAT 'LF by-'))     
                                                                      
   /* IF WE HAVE A LOGICAL FILE IN ARRIVAL SEQUENCE           */      
             IF         COND(&APNKYF *EQ 0) THEN(DO)                  
               CHGVAR     VAR(&TEXT) VALUE(&TEXT *TCAT 'Arrival +     
                            Sequence')                                
               GOTO       CMDLBL(PROCESS)
ENDDO                                                 
            CHGVAR     VAR(&FLDSIZE) VALUE(10)                    
            CHGVAR     VAR(&TXTSIZE) VALUE(50)                    
            GOTO CHKFSIZE                                         
 BEFTSIZE:  GOTO CHKTSIZE                                         
 AFTTSIZE:                                                         
   /* IF WE HAVE MORE KEYS THAN WILL FIT, MAKE THE LAST KEY A  */  
   /*  CONTINUANCE                                             */  
             CHGVAR     VAR(&COUNT) VALUE(&TXTSIZE + &FLDSIZE + 1) 
             IF         COND(&COUNT *GT 46) THEN(DO)               
               CHGVAR     VAR(&TEXT) VALUE(&TEXT *TCAT '....')     
               GOTO PROCESS                                        
             ENDDO                                                 
                                                                   
             CHGVAR     VAR(&TEXT) VALUE(&TEXT *TCAT &APKEYF)      
                                                                   
   /* DONT PUT A COMMA AFTER THE LAST KEY FIELD               */   
             IF         COND(&APKEYN *LT &APNKYF) THEN(CHGVAR +    
                          VAR(&TEXT) VALUE(&TEXT *TCAT ','))       
                                                                   
             GOTO       CMDLBL(READ)
  CHKFSIZE:                                                          
  /* GET LENGTH OF FIELD TEXT */                                     
             IF         COND(%SST(&APKEYF &FLDSIZE 1) *GT ' ' *OR +  
                          &FLDSIZE = 1) THEN(GOTO CMDLBL(BEFTSIZE))  
             CHGVAR     VAR(&FLDSIZE) VALUE(&FLDSIZE - 1)            
             GOTO       CMDLBL(CHKFSIZE)                             
  CHKTSIZE:                                                          
  /* GET CURRENT LENGTH OF TEXT FIELD */                             
             IF         COND(%SST(&TEXT &TXTSIZE 1) *GT ' ' *OR +    
                          &TXTSIZE = 1) THEN(GOTO CMDLBL(AFTTSIZE))  
             CHGVAR     VAR(&TXTSIZE) VALUE(&TXTSIZE - 1)            
             GOTO       CMDLBL(CHKTSIZE)                             
  PROCESS:                                                           
             CHGPFM     FILE(&LIB/QDDSSRC) MBR(&FILE) TEXT(&TEXT)    
             CHGLF      FILE(&FILELIB/&FILE) TEXT(&TEXT)             
             MONMSG     MSGID(CPF0000)                               
  ENDPGM:                                                            
             ENDPGM

---------------------------
About the author: Tim is vice president of Technical Services at Interlink Technologies in Maumee, Ohio. 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
==================================


Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close