×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




try the QDBRTVFD API to retrieve the key field information.

Here's the procedure definition I use:

 * List Key Fields (QDBRTVFD retrieve file desc)API Procedure      
DListFileDesc     pr                  ExtPgm('QDBRTVFD')           
d  OutputData                32766a   Options(*Varsize)            
d  OutputDataLen                10i 0 Const                        
d  CUSPFNameRet                 20a                                
D  PFRcdFmt                      8a   Const                        
d  CUSPFName                    20a   Const                        
D  RcdFmt                        8a   Const                        
d  OverrideProc                  1a   Const                        
d  System                       10a   Const                        
d  FormatType                   10a   Const                        
d  ErrorCode                 32766a   options(*varsize) 

 * List File Description Header DS      
D  FDHDS          ds                    
D  FDHBytesRet                  10i 0   
D  FDHBytesAvail                10i 0   
D  FDHMaxKeyLen                  5i 0   
D  FDHKeyCount                   5i 0   
D  FDHReserved                  10a     
D  FDHFormatCnt                  5i 0   
D  KeyRecFmt                    10a     
D  KeyReserve                    2a     
D  Key#OfKeys                    5i 0   
D  KeyReserv1                   14a     
D  KeyInfoOffset                10i 0   

                                          
 * List Key Information DS                
D KeyDS           ds                      
D  KeyIntName                   10a       
D  KeyExtName                   10a       
D  KeyDtaType                    5i 0     
D  KeyFldLen                     5i 0     
D  Key#OfDigits                  5i 0     
D  KeyDecPos                     5i 0     
D  KeyAttrFlg                    1a       
D  KeyAltLen                     5i 0     
D  KeyAltName                   30a       
D  KeyReserv3                    1a       
D  KeyAttrFlg1                   1a       
D  KeyReserv4                    1a                  

c                   CallP(E)  ListFileDesc(OutputData:  
c                             OutputDataLen:            
c                             CUSPFNameRet:             
c                             'FILD0300':               
C                             CUSPFName:                
c                             RcdFmtName:               
c                             OverrideProc:             
c                             '*LCL':                   
c                             '*EXT':                   
c                             ErrorDS)                  

                                                                      
 * If Any Errors Occur or No Key Fields Found, Set Number Of Keys To 0
c                   If        OutputData=*Blanks                      
C                             OR %Error                               
c                             OR %len(%Trim(OutputData))=0            
c                   Eval      Key#OfKeys=0                            
c                   Else                                              
c                   MoveL     OutputData    FDHDS                     
c                   EndIf                                             
                                                                      
 * Process Key Information Stored in the OutputData Variable          
c                   Eval      StrPos=KeyInfoOffset+1                  
c                   Do        Key#OfKeys                              
c                   Eval      KeyDS=%Subst(OutputData:StrPos:         
c                             +%Size(KeyDS))                          

Anyway you should be able to adapt this code for your pgm....

Thanks,
Tommy Holden


-----Original Message-----
From: Tony Carolla [mailto:carolla@xxxxxxxxx]
Sent: Thursday, September 23, 2004 10:51 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Key field info


I have written a quick little app to list the fields in a physical
file, using the QUSCRTUS, QUSPTRUS, QUSLRCD and QUSLFLD APIs.  The
fields are placed in a subfile, and listed for the user.  It's
basically like DSPFFD, without all the extra 'stuff' that I don't
usually need to see at a glance.  Neato.

I would like to also indicate which fields are key fields, and what
order these key fields are in.  I can't see which API would help me
with this detail.  I don't see any option on the QUSLFLD API to show
this, nor on the QUSLRCD API.

Also, I don't see a way of knowing how many fields are returned from
the QUSLFLD API.  I currently have a DS based on a POINTER to the user
space, and I increment the pointer after each field retrieval to the
subfile.  I test the first character of the field name for containing
an alpha character, and if it does not, I assume I have reached the
end of the loop.  Kind of messy, but it works.  Is there a better way?

TIA

Tony Carolla, 
Programmer/Analyst
MedAmerica Billing Services, Inc.

-- 
"Enter any 11-digit prime number to continue..."
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.