Try OpenEdge Now
skip to main content
Managing ABL Applications
R-code Features and Functions : R-code CRCs and procedure integrity : RCODE-INFO handle : Example: Determining which files are affected by a database change
 
Example: Determining which files are affected by a database change
The following procedure demonstrates how you can use the RCODE-INFO system handle with the TABLE-LIST and TABLE-CRC-LIST attributes to help determine which files you need to recompile based upon a database change. TABLE-LIST generates a list of all the database tables that are referenced in the procedure file. TABLE-CRC-LIST generates a list of the corresponding table CRC values stored in the compiled procedure file. This example procedure then compares the CRC values in the procedure file with those stored in the database. If any of the values differ, you get a message stating that the procedure needs to be recompiled, as shown:
DEFINE VARIABLE crclst AS CHARACTER NO-UNDO.
DEFINE VARAIBLE hBuff  AS HANDLE    NO-UNDO.
DEFINE VARIABLE ix     AS INTEGER   NO-UNDO.
DEFINE VARIABLE tbllst AS CHARACTER NO-UNDO.
ASSIGN
  RCODE-INFO:FILE-NAME = "main.r"
  tbllst               = RCODE-INFO:TABLE-LIST
  crclst               = RCODE-INFO:TABLE-CRC-LIST.
REPEAT ix = 1 TO NUM-ENTRIES(tbllst)
  CREATE BUFFER hBuff FOR TABLE ENTRY(ix, tbllst).
  IF hBuff:CRC-VALUE = INTEGER(ENTRY(ix, crclst)) THEN
    MESSAGE "main.r does not need to be recompiled".
  ELSE
    MESSAGE "main.r needs to be recompiled".
  DELETE OBJECT hBuff.
END.
This procedure does not generate any warnings or error messages. If the r-code file was not compiled with any tables, then the attribute returns the empty string. If the file is not found or is corrupted, the attribute returns the Unknown value (?).