ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

determine key fields in PF

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • determine key fields in PF

    I looked at dspffd to an outfile and some of the catalogue files... I'm needing to identify key fields in PF's/LF's... where can I query for that info?

  • #2
    The info can be obtained from DSPFD. Search on "Key field" (around the 3rd page down).

    Comment


    • #3
      Hi Jay
      You could try this:
      Code:
      select *  from qsys2/syskeys
      where index_schema = 'mylib'
      and index_name = 'myfile'
      order by ordinal_position
      Alternatively, XrefIT has this utility available with a little more info added.

      Click image for larger version

Name:	xk.jpg
Views:	0
Size:	99.0 KB
ID:	146384
      Regards

      Kit
      http://www.ecofitonline.com
      DeskfIT - ChangefIT - XrefIT
      ___________________________________
      There are only 3 kinds of people -
      Those that can count and those that can't.

      Comment


      • #4
        fantastic thanks guys!

        Comment


        • #5
          Or if you want to use it dynamically in a program, you can always use the standard IBM API to get the keys, to use in an RPGLE.. below is an example:

          The D-Spec:
          Code:
           **-- Output Key Related Variables
          D#FKeyS           S             10A                        
          D#FKeyDS          DS                                        
          D #FKey1                        10A   Overlay(#FKeyDS)      
          D #FKey1Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey2                        10A   Overlay(#FKeyDS:*Next)
          D #FKey2Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey3                        10A   Overlay(#FKeyDS:*Next)
          D #FKey3Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey4                        10A   Overlay(#FKeyDS:*Next)
          D #FKey4Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey5                        10A   Overlay(#FKeyDS:*Next)
          D #FKey5Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey6                        10A   Overlay(#FKeyDS:*Next)
          D #FKey6Info                    54A   Overlay(#FKeyDS:*Next)
          D #FKey7                        10A   Overlay(#FKeyDS:*Next)
          D #FKey7Info                    54A   Overlay(#FKeyDS:*Next)
          
           **-- Fetch File Key (API) Related Variables                    
          D#Access          S              8A                    
          D#RFmtN           S             10A                    
          D#OvrP            S              1A                    
          D#FSys            S             10A                    
          D#FmtTp           S             10A                    
          D#ErrorDS         S             16A   Inz(X'00000000') 
          D#QualFile        S             20A                    
          D#FData           S            736A                    
          D#FDataLen        S              4A   Inz(X'000002E0') 
          D#QualRtnF        S             20A
          The Subroutine itself, where:
          • P#FName is the file name.
          • P#LName is the library name.
          • #FKeyDS is the response keys structured as the above Data Structure.
          Code:
          C     GetFKeys      BegSR                                      
           **--                                                          
          C                   Monitor                                    
          C                   Eval      #Access   = 'FILD0300'          
          C                   Eval      #RFmtN    = '*FIRST'            
          C                   Eval      #OvrP     = '0'                  
          C                   Eval      #FSys     = '*LCL'              
          C                   Eval      #FmtTp    = '*EXT'              
          C                   Eval      #QualRtnF = [COLOR=#FF0000]P#FName [/COLOR]+[COLOR=#FF0000]P#LName     [/COLOR]
          C                   Eval      #QualFile = [COLOR=#FF0000]P#FName [/COLOR]+[COLOR=#FF0000]P#LName     [/COLOR]  
          C                   Call      'QDBRTVFD'                      
          C                   Parm                    #FData            
          C                   Parm                    #FDataLen          
          C                   Parm                    #QualRtnF          
          C                   Parm                    #Access            
          C                   Parm                    #QualFile          
          C                   Parm                    #RFmtN            
          C                   Parm                    #OvrP                    
          C                   Parm                    #FSys                    
          C                   Parm                    #FmtTp                    
          C                   Parm                    #ErrorDS                  
          C                   Eval      [COLOR=#FF0000]#FKeyDS[/COLOR]   = %SubSt(#FData:57:448)      
           **-- On Error:                                                      
          C                   On-Error  *All                                              
          C                   ExSR      WriteError                                            
          C                   EndMon                                            
          C                   EndSR

          Comment

          Working...
          X