Page 1 of 1

Wait For File Activity generating incorrect code?

Posted: Mon Sep 26, 2011 8:21 pm
by djbarham
I've been having problems with a Wait For File activity going to the exception handler rather than the links indicated by triggers.

After playing around with different options and examining the generated code, it is my belief that a Wait For File Activity generates incorrect job control code if
* you have "Automatically handle activities that fail" enabled AND
* you do not have an "Otherwise" expression on one of the links.

The effect of the incorrect code is that it checks for a failure (any response <> 0) and branches to the error handler BEFORE it checks the trigger conditions.

Maybe I misunderstand how I am supposed to use this, but this seems wrong to me.

I was hoping to have one link check for DSJE.NOERROR, a second link check for DSJE.TIMEOUT and any other failures handled by the error handler.

Is anyone able to shed any light on this behaviour, or at least provide tips the conditions they usually use with a wait for file activity?

Posted: Mon Sep 26, 2011 8:54 pm
by ray.wurlod
Timeout IS regarded as "failure" in the Wait For File activity. All you need are success and failure triggers. No other trigger will be honoured.

Posted: Mon Sep 26, 2011 9:13 pm
by djbarham
Thanks Ray.

Yeah, I'm starting to think that I'll skip the WFF activity altogether. I really just want to know of the file is there or not, so I think I'll use a Unix command instead.

Posted: Mon Sep 26, 2011 9:36 pm
by chulett
To check for file existence, set the timeout to zero. Then as Ray noted, you just need "OK" and "Otherwise" triggers from the stage - the former for the file being found and the latter for it not being found. Those two triggers should also tell the generated code that you are handling any errors (since it covers all bases) and the "Automatically handle" option should no longer be an issue.

Posted: Mon Sep 26, 2011 9:52 pm
by djbarham
chulett wrote:To check for file existence, set the timeout to zero.
Yes, I was doing that, but a time out still causes a warning to be logged. No file is a perfectly acceptable result for me so I'd prefer not to have the warning.

I'm now using a Unix if command and it is working fine. Still had to resort to a full "if then else" though to avoid a 1 being returned to DataStage (eg from "test ..." or "[ -f ... ] ..." )

eg

if [ -f filename ] ; then echo "FILE" ; else echo "NOFILE" ; fi

Thanks for the help, Ray and Craig.