Page 1 of 1

Raise Error not aborting Project

Posted: Tue May 20, 2014 10:49 am
by Harold76
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>

Re: Raise Error not aborting Project

Posted: Tue May 20, 2014 7:06 pm
by Support_Rick
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>