Return codes

Return codes, which Enrichment stores in the system variable %%RC, are integer values that indicate the success or failure of the function call. While each function may set a specific return code based on its result, all such functions follow these conventions:

  • A return code of 0 indicates that the function was successful.
  • A negative return code (for example, -1) indicates that invalid arguments were used or a severe error occurred.
  • A positive return code (for example, 1) indicates that the function was not successful or was partially successful.
Note: To handle errors that may result from calls to Enrichment functions, you should always include logic to check the return code value. Enrichment does not provide any error messages if a function call fails.

The %%RC contains the return code from the most recent function call. As shown in the figure below, you can use %%RC to specify alternate processing.

%%AMOUNT = FINDNUM(%%LINE1)    /*Find amt in line 1 or 2 */
IF %%RC <> 0 THEN              /* If amount is not found */
  %%AMOUNT = FINDNUM(%%LINE2)
  IF %%RC <> 0 THEN             /*Set to 12 if still not found */
     %%AMOUNT = 12
  ENDIF
ENDIF