#!/bin/ksh
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#


########################################################################
#                                                                      #
# EBM BATCH JOB MACRO :     GOTO                                       #
# Purpose             :     Specifies a label in th jobstream where    #
#                           execution is to resume. EBM only searches  # 
#                           forward for a label name used with GOTO.   # 
#                           If the label is not found, the job         # 
#                           terminates.                                #
########################################################################
. verify_jobstatus
. beginjob.${EBMSYS}.${JON}
. current_proc_level.${EBMSYS}.${JON}

if [ "a$GOTO_TESTCOND" = "a" -a "a$GOTO_TESTRC" = "a" ]
then
   GOTO_TESTCOND=1; export GOTO_TESTCOND
   GOTO_TESTRC=1; export GOTO_TESTRC

   if [ -f label.${EBMSYS}.${JON}.${PROC_LEVEL} ]
   then
      . label.${EBMSYS}.${JON}.${PROC_LEVEL}
   fi

   if [ "a$BATCH_MODE" = "aMVS" ]
   then
      . check_bypass_step
      if [ "$BYPASS" = "YES" ]
      then
         exit 0
      fi
   fi
fi


if [ -f beginproc.setparms.${EBMSYS}.${JON}.${PROC_LEVEL} ]
then
   . beginproc.setparms.${EBMSYS}.${JON}.${PROC_LEVEL}
fi

if [ -f setparm.${EBMSYS}.${JON}.${PROC_LEVEL} ]
then
   . setparm.${EBMSYS}.${JON}.${PROC_LEVEL}
fi



for argument in $*
do
   i=`eval echo $argument`
   case $i in 
      name=*)
         NAME="`eval echo $i|cut -f2 -d'='`" ; export NAME
      ;;
      verbose*)
         VERBOSE=YES ; export VERBOSE
       ;;

      *)
         NAME=$i ; export NAME
      ;;
  esac
done   
if [ "a$NAME" != "a" ]
then
   if [ "$NAME" = "END_JOB" ]
   then
      NAME="${NAME}.$$"  ; export NAME
   fi
   if [ "$PROC_LEVEL" -eq 0 ]
   then
      cat <$DEVNULL > restart.${EBMSYS}.${JON}
      echo "$NAME" >> restart.${EBMSYS}.${JON}
   else
      cat <$DEVNULL > prestart.${EBMSYS}.${JON}
      echo "$NAME" >> prestart.${EBMSYS}.${JON}
   fi
   touch bypassfile.${EBMSYS}.${JON}
else
   print_message GOTO "Label or stepname is required"
   . set_jobstatus_abort
fi
exit 0
