#!/bin/ksh
#whatwfmailerdebug ()
#------------------------------------------------------------------------------#
#    Module Name:  whatwfmailerdebug                                           #
#                                                                              #
#    Purpose:      Report on the WorkFlow Mailer DeBug Script.                 #
#                                                                              #
#    Maintenance                                                               #
#    Date          Author        Description                                   #
#    -----------   ------------  --------------------------------------------  #
#    01-Feb-2007   M.Barone      Module design/creation                        #
#------------------------------------------------------------------------------#
{
        DIRNAM=$(dirname $0)
	ORASID=$(echo $CONTEXT_NAME | cut -f1 -d'_')
	HNAME=$(uname -n)

        #----------------------------------------------------------------------#
        #  TEST:  Number ($#) of arguments passed to this function?            #
        #----------------------------------------------------------------------#
	if      [ $# = 0 ]
	then
	    clear
	    echo
	    echo  " #--------------------------------------------------------#"
	    echo  " # whatwfmailerdebug:        Oracle Apps WorFlow Services #"
	    echo  " #--------------------------------------------------------#"
	    echo

	    #------------------------------------------------------------------#
	    #  Trap:  Set CNTL-C CNTL-D CNTL-\ Before Password Protection      #
	    #------------------------------------------------------------------#
	    trap        "stty echo; return"     2
	    trap        "stty echo; return"     3
	    stty -echo

	    read PASSWD?" Please Enter the Oracle APPS Passwd: "

	    stty echo
	    echo
	    #------------------------------------------------------------------#
	    #  Trap:  Reset CNTL-C CNTL-D CNTL-\ After Password Protection     #
	    #------------------------------------------------------------------#
	    trap        2
	    trap        3

	    read WFNOTE?"        Enter the WorkFlow Notification ID:    "
	    clear
	else
	    PASSWD=$1
	    WFNOTE=$2
	    clear
	fi


#------------------------------------------------------------------------------#
#  Initialize                                                                  #
#------------------------------------------------------------------------------#
	SPOOLNM=/tmp/whatwfmailerdebug_$$.txt
	cd /tmp

#------------------------------------------------------------------------------#
#  SQL*Plus ("Here-Document")                                                  #
#------------------------------------------------------------------------------#
sqlplus  -s  /nolog  <<-END_FILE

	CONNECT  APPS/$PASSWD

	SPOOL ${SPOOLNM}
	@$FND_TOP/sql/wfmlrdbg.sql $WFNOTE

EXIT;
END_FILE


mv  wfmlrdbg${WFNOTE}.html /tmp/whatwfmailerdebug${WFNOTE}.html
print
print "Please see /tmp/whatwfmailerdebug${WFNOTE}.html"
print
}
