Raise Error not aborting Project

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

Harold76

Posts: 6
Joined: Wed Apr 30, 2014 11:06 am

Post by Harold76 » Tue May 20, 2014 10:49 am
I have a project that will check for the presence of a file and loop until either the file is no longer there or it passes a threshold. If the file isn't there and the threshold is passed, then it should abort. But the Raise Error task is not aborting the Project. It's continuing past the Raise Error task and executing the other tasks.

Code: Select all
<project name="MFFileCheck_Loop_Iterate" mainModule="Main" version="2.0">
	<description>For checking if a file exists on the mainframe</description>

	<module name="Main" onError="setVariable:hdfound="FALSE"">

		<setVariable label="hdfound" name="hdfound" value="TRUE" version="2.0" />


		<setVariable label="MFFileName" name="MFFileName" value="T.CS.WH.SOA.HDDXFILE.DAT.UP" version="2.0" />

		<doWhileLoop condition="${hdfound eq "TRUE"}" id="MFCheck" currentIterationVariable="threshold">

			<ftp resourceId="MVS" outputSessionId="FTPSession" user="******" password="******" version="1.0" onError="setVariable:hdfound=FALSE">
				<exec command="cwd &apos;ftintb01&apos;" />
				<list label="ListMFfiles" fileListVariable="filelist" numFilesFoundVariable="filecount">
					<fileset dir="&apos;${MFFileName}&apos;" />
				</list>
			</ftp>


			<delay label="Wait 10 Seconds" time="10" timeUnit="seconds" version="1.0" />

			<exitLoop condition="${threshold ge 10}" loopId="MFCheck" />
		</doWhileLoop>

		<raiseError label="Threshold_Passed" version="1.0" executeOnlyIf="${threshold ge 10}">
			<message>Threshold passed. Failing project</message>
		</raiseError>


		<ftp resourceId="MVS" inputSessionId="${FTPSession}" user="******" password="********" listParser="mvs" version="1.0">
			<exec label="cwd &apos;ftintb01&apos;" command="cwd &apos;ftintb01&apos;" />
			<list label="ListMFfiles" fileListVariable="hdfilelist" numFilesFoundVariable="hdfilecount">
				<fileset dir="&apos;${MFFileName}&apos;" />
			</list>
		</ftp>


		<ftpCloseSession label="Close FTP Session" sessionId="${FTPSession}" version="1.0" />

		<if label="If File Does Not Exist" condition="${hdfound eq "FALSE"}">

			<print label="File Not Found" version="1.0">
				<![CDATA[FILE NOT FOUND]]>
			</print>

		</if>
		<if label="If File Exists" condition="${hdfound eq "TRUE"}">

			<print label="File Found" version="1.0">
				<![CDATA[File ${MFFileName} found]]>
			</print>

		</if>
	</module>

</project>

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue May 20, 2014 7:06 pm
Harold,

Try something like this and see if it doesn't help you get what you're looking for. Please let me know if there's any questions.
Code: Select all
<project name="MFFileCheck_Loop_Iterate" mainModule="Main" version="2.0">

	<description>For checking if a file exists on the mainframe</description>

	<module name="Main">

		<setVariable label="Init MFFileName" name="MFFileName" value="T.CS.WH.SOA.HDDXFILE.DAT.UP" version="2.0" />

		<forLoop label="Loop til found or Threshold" beginIndex="1" endIndex="${Threshold}" step="1" currentIterationVariable="CurrLoop">

			<setVariable label="Init FileCount" name="FileCount" value="0" version="2.0" />

			<ftp label="Connect to Source Server" resourceId="MVS" inputSessionId="${FTPSession}" outputSessionId="FTPSession" user="******" password="******" version="1.0">
				<exec label="cwd &apos;ftintb01&apos;" command="cwd &apos;ftintb01&apos;" />
				<list label="ListMFfiles" fileListVariable="filelist" numFilesFoundVariable="filecount">
					<fileset dir="&apos;${MFFileName}&apos;" />
				</list>
			</ftp>

			<exitLoop condition="${ ( FileCount gt 0 ) or ( CurrLoop ge Threshold ) }" />

			<delay label="Wait a second" time="${Wait_Time}" timeUnit="seconds" version="1.0" />

		</forLoop>

		<if label="File Not Found or Threshold Passed?" condition="${ ( FileCount eq 0 ) or ( CurrLoop ge Threshold ) }">

			<raiseError label="FNF or Threshold Passed" version="1.0">
				<message>
File not Found or Threshold was Passed.
Aborting Project ...
        </message>
			</raiseError>

			<exitModule version="1.0" />

		</if>

		<setVariable label="Init FileCount" name="FileCount" value="0" version="2.0" />

		<ftp label="Connect to Source Server" resourceId="MVS" inputSessionId="${FTPSession}" user="******" password="********" listParser="mvs" version="1.0">
			<exec label="cwd &apos;ftintb01&apos;" command="cwd &apos;ftintb01&apos;" />
			<list label="ListMFfiles" fileListVariable="FileList" numFilesFoundVariable="FileCount">
				<fileset dir="&apos;${MFFileName}&apos;" />
			</list>
		</ftp>

		<exitModule version="1.0" executeOnlyIf="${ FileCount eq 0 }" />

		<print label="File Found" version="1.0">
			<![CDATA[
File was found!
===============
${FileList}
      ]]>
		</print>

	</module>

	<variable name="Threshold" value="10" />
	<variable name="Wait_Time" value="10" />
</project>
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1