RETURNCODE_CHECK () {
#----------------------------------------------------------------------------------------------------- 
# Test last AIX return code from any call or DB2 operation against a maximum allowable return code.
# Unconditionally display the entire log file to stderr on an error and exit. The caller exports $LOG.
# Note that in general called functions in $FPATH do not exit, but this one does.
# Arguments: $1 return code to test $2 maximum allowable return code $3 ksh debug switch (+x or -x).
#----------------------------------------------------------------------------------------------------- 

set $3 ; DEBUG=$3 
typeset -i ARG1=$1 ARG2=$2
if [[ $ARG1 -gt $ARG2 ]]
then RESET_OUTPUT
     cat $LOG
     MESSAGE "$0 Ends with error(s), return code $ARG1. Please review log file $LOG . " BOLD E $DEBUG
     MESSAGE "The log file is displayed above for ease of reference. " PLAIN I $DEBUG
     exit $ARG1
fi
}
