#!/bin/ksh
###############################################################################
#
# EBM BATCH JOB MACRO :     MAXRC
# Purpose             :     Returns the maximum return code set by any of the
#                           job's preceding steps. If no previous step was 
#                           executed MAXRC returns zero. 
#
###############################################################################
. verify_jobstatus
. beginjob.${EBMSYS}.${JON}

max_return_code=0
if [ -f ${JON}_RETCOD ]
then
   cat ${JON}_RETCOD | while read ENTRY
   do
      return_code=`eval echo $ENTRY | cut  -f2 -d' '`
      if [ "$return_code" -gt "$max_return_code" ]
      then
         max_return_code=$return_code
      fi
   done
fi
MAXRC=$max_return_code; export MAXRC
echo $MAXRC
