2 of 2 people found this helpful
In your rule file you have specified the following:
ON_FILEWATCH /applications/data/transfer/BANCLL74_%%$ODATE*.OK CREATE
The options for this are:
ON_FILEWATCH <fileName>(absolute path) [CREATE/DELETE] [min_size] [min_detect] [wait_time]
[start_time] [cyclic_interval] [wildcards] [minimal_file_age]
You have not specified a wait_time so that would default to a value of 0 meaning there is no time limit to wait:
Maximum time (in minutes) to run the process without detecting the file at its minimum size (CREATE) or detecting its deletion (DELETE). If the file is not detected/deleted in this specified time frame, the process terminates with an error return code, as described in ctmfw- return codes table below.. Default: 0 (no time limit).
Maybe you can try adding two additional lines like:
ON_FILEWATCH /applications/data/transfer/BANCLL74_%%$ODATE*..OK CREATE
Control-M variables like %%$ODATE can only be used within a job definition. The rule file is an external file which cannot resolve Control-M variables. My suggestion is to create a "normal" file watcher job and make use of "Capture from job output" to get the filename. One possible solution is in a post that I have replied to Looking for suggestions on the following use case . In my example, I'm capturing the value into a Smart folder variable. In your case, it should be global variable or whatever variable type that is in the scope of the other job that requires it. The value of Path should be "/applications/data/transfer/BANCLL74_%%$ODATE*.OK". It's important to enclose the path in "". After job has been ordered, view the job output to confirm that the filewatcher is watching for the correct file.
sometimes it works work, but anyway the correct spec. in the Job is as follows:
%%$ODATE..OK or depends on your request %%$ODATE.*.OK
You have to add one dot as delimiter for the autoedit and another one that is part of the filename themselve.
3 of 3 people found this helpful
I had a similar issue a while ago - as Mun Keong Lee noted, variables don't work in filewatcher scripts..
In my case, I needed to use a filewatcher script (filewatcher job type/form, or instream AFT/MFT filewatcher wouldn't do what I needed), so I got around it by adding an additional job with PARM1 = %%$ODATE that created the filewatcher script - including the value of %%$ODATE rather than variable name - immediately before the actual job, then using the newly created filewatcher script as the input script for the filewatcher.
A slightly modified version of the script that I put together is below (hope it's readable - I can't see a way here to format a code block). There may be a more elegant way to do it, but it worked for me and did what I needed, although it was quite a few years ago that I wrote it, so no guarantees..
---> Start script
# $1 = PARM1 %%$ODATE
# Delete file if it exists
if [ -f $FW_INPUT_SCRIPT ];
echo "File exists - deleting"
# Create filewatcher input file.
# Required as FW input files can't contain variables.
echo \# This is a ControlM File Watcher job, and created AS NEEDED > $FW_INPUT_SCRIPT
echo \# Filewatcher for xxxx >> $FW_INPUT_SCRIPT
echo \# ------------------------------------------------------------------ >> $FW_INPUT_SCRIPT
echo \# Mandatory Parameters >> $FW_INPUT_SCRIPT
echo INTERVAL 1 \# Sleep interval \(seconds\) >> $FW_INPUT_SCRIPT
echo FROM_TIME 0000 \# Starting time for all files \(hhmm\) >> $FW_INPUT_SCRIPT
echo MIN_SIZE 0 \# Minimum size for all files \(bytes\) >> $FW_INPUT_SCRIPT
echo MIN_DETECT 5 \# Number of iterations for all files >> $FW_INPUT_SCRIPT
echo WAIT_TIME 180 \# Time limit for all files \(minutes\) >> $FW_INPUT_SCRIPT
echo \# ON_FILEWATCH statements >> $FW_INPUT_SCRIPT
echo ON_FILEWATCH /SOMEDIRECTORY/FILEABC$1.csv CREATE >> $FW_INPUT_SCRIPT
echo ON_FILEWATCH /SOMEDIRECTORY/FILEXYZ$1.csv CREATE >> $FW_INPUT_SCRIPT
echo ON_FILEWATCH /SOMEDIRECTORY/FILE000$1.txt CREATE >> $FW_INPUT_SCRIPT
echo THEN >> $FW_INPUT_SCRIPT
echo DO_OK >> $FW_INPUT_SCRIPT
echo ELSE >> $FW_INPUT_SCRIPT
echo DO_NOTOK >> $FW_INPUT_SCRIPT
echo END_ON >> $FW_INPUT_SCRIPT
---> End script