Salesforce

Does the RCODE-INFO handle provide information on INDEX CRCs?

« Go Back

Information

 
TitleDoes the RCODE-INFO handle provide information on INDEX CRCs?
URL Namedoes-the-rcode-info-handle-provide-information-on-index-crcs
Article Number000172251
EnvironmentProduct: OpenEdge
Version: All Supported Versions
OS: All Supported Platforms
Question/Problem Description
The RCODE-INFO system handle provides a list of tables and the individual CRC values for each table, but is it possible to get a list of index CRCs for indexes referenced in an rcode file?
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
At the time of this writing, the RCODE-INFO system handle does NOT provide information about indexes that are referenced in the r-code, nor does it provide the referenced indices' CRC values.

To get this information now one would have to compile their programs using the XREF option and search the output for the SEARCH keyword (all in CAPS) to determine which indexes are referenced by the program.

One strategy for ensuring you'll always be able to reference the index CRCs as necessary would include modifying the application compilation process to include the XREF option and always generate XREF output along with the r-code.  

Then, when you need to find the index CRCs on given r-code files you can parse the XREF file to determine which indexes are used by it and run code similar to the following to find the CRC list:

Note: To use the below code you must be connected to all databases referenced in the r-code.
FUNCTION getIndexCRC RETURNS CHARACTER ( INPUT pcDatabase AS CHARACTER,
                                         INPUT pcTable    AS CHARACTER,
                                         INPUT pcIndex    AS CHARACTER )
         FORWARD.
         
DEFINE VARIABLE cInput    AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cDatabase AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cTable    AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cIndex    AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cMessage  AS CHARACTER   NO-UNDO 
    INITIAL "RCODE-CRC for foo.r~n".

/* This code assumes that the XREF output was generated when the r-code
   file was compiled.  Using an example of foo.r, this code reads in foo.xrf */
INPUT FROM foo.xrf.
REPEAT:
    IMPORT UNFORMATTED cInput.
    /* Use COMPARE so that you can perform a CASE-SENSITIVE comparison. 
       Just in case there is a string in the output with the word "search" 
       in it. */
    IF COMPARE(ENTRY(4,cInput," "),"EQ","SEARCH","CASE-INSENSITIVE") THEN
        ASSIGN cDatabase = ENTRY(1,ENTRY(5,cInput," "),".")
               cTable    = ENTRY(2,ENTRY(5,cInput," "),".")
               cIndex    = ENTRY(6,cInput," ")
               cInput    = getIndexCRC(cDatabase,cTable,cIndex)
               cMessage  = cMessage + (IF (cMessage GT "") EQ TRUE THEN CHR(10) ELSE "") +
                           "Index: " + cDatabase + "." + cTable + "." + cIndex +
                           " - CRC: " + cInput.
END.
INPUT CLOSE.
   
MESSAGE cMessage
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

FUNCTION getIndexCRC RETURNS CHARACTER ( INPUT pcDatabase AS CHARACTER,
                                         INPUT pcTable    AS CHARACTER,
                                         INPUT pcIndex    AS CHARACTER ):
    DEFINE VARIABLE cIndexCRC AS CHARACTER   NO-UNDO.
    
    DEFINE VARIABLE hFile  AS HANDLE      NO-UNDO.
    DEFINE VARIABLE hIndex AS HANDLE      NO-UNDO.
    
    CREATE BUFFER hFile  FOR TABLE pcDatabase + "._file"  NO-ERROR.
    CREATE BUFFER hIndex FOR TABLE pcDatabase + "._index" NO-ERROR.
    
    hFile:FIND-FIRST("WHERE _file-name EQ ~"" + pcTable + "~"",
                     NO-LOCK) NO-ERROR.
    IF hFile:AVAILABLE THEN DO:
        hIndex:FIND-FIRST("WHERE _file-recid EQ " + STRING(hFile:RECID) +
                          " AND _index-name EQ ~"" + pcIndex + "~"",
                           NO-LOCK) NO-ERROR.
        
        IF hIndex:AVAILABLE THEN
            cIndexCRC = TRIM(hIndex:BUFFER-FIELD("_idx-CRC"):STRING-VALUE).
         ELSE cIndexCRC = "".
    END.
    
    DELETE OBJECT hFile  NO-ERROR.
    DELETE OBJECT hIndex NO-ERROR.
    
    RETURN cIndexCRC.
    
END FUNCTION.

 
Workaround
Notes
Keyword Phrase
Last Modified Date2/5/2019 9:33 PM

Powered by