Index: trunk/DataCheck/Sourcefile.sh
===================================================================
--- trunk/DataCheck/Sourcefile.sh	(revision 18766)
+++ trunk/DataCheck/Sourcefile.sh	(revision 18767)
@@ -385,4 +385,7 @@
       start)   printprocesslog "DEBUG setstatus start"
                starttime="Now()"
+               ;;
+      startj)  printprocesslog "DEBUG setstatus startj"
+               starttime="'1971-01-01 01:01:01'" # special recognizable datetime, i.e. "reserved by JobManager for processing"
                ;;
        stop)   case $check in
@@ -460,5 +463,7 @@
    if [ "$1" = "start" ]
    then 
-      query=$query" AND ISNULL("$step"Status.fStartTime) "
+      # process job only if it is not yet being processed
+      #  i.e. either StartTime NULL or '1971-01-01 01:01:01' (reserved by JobManager for processing)
+      query=$query" AND (ISNULL("$step"Status.fStartTime) OR "$step"Status.fStartTime='1971-01-01 01:01:01')"
    fi
    # add row count to know how many rows have been changed
@@ -564,2 +569,74 @@
 }
 
+# missing: implement usage of this function in Fill*.sh
+function check_file_avail()
+{
+   if [ "$1" = "" ]
+   then
+      echo "Please give file name as first argument."
+      finish
+   fi
+   if [ "$transferdelay" = "" ]
+   then 
+      # setup where immediate report of problem is needed, i.e. mainly LP
+      checknight=`date +%Y%m%d --date="-19HOUR"`
+   else
+      # any setup where transfer might cause a delay in arrival of files
+      checknight=`date +%Y%m%d  --date="-${transferdelay}day"`
+   fi
+   
+   printprocesslog "INFO checking availability of "$1
+   if ! [ -e $1 ]
+   then 
+      # treat raw files differently than auxfiles
+      checkraw=`echo $1 | grep -E -o raw`
+      if [ "$checkraw" = "raw" ]
+      then 
+         if [ $filenight -le $checknight ] 
+         then 
+            printprocesslog "WARN "$1" not found."
+         else
+            printprocesslog "INFO "$1" not found."
+         fi
+         return 1
+      fi
+      # only for aux files check of DB is needed
+      filenight=`basename $1 | cut -c 1-8`
+      query="SELECT COUNT(*) FROM RunInfo WHERE fNight="$filenight" AND fRunTypeKey=1"
+      numdatruns=`sendquery`
+      # for some files it is more severe when they are missing
+      checkfile=`echo $1 | grep -E -o 'DRIVE'\|'RATES'`
+      # print INFO/WARN/ERROR depending on severity
+      if [ $numdatruns -eq 0 ]
+      then 
+         # in case no data runs are available from this night, it's not a problem if files are missing
+         printprocesslog "INFO "$1" not found."
+      else
+         if [ "$checkfile" != "" ]
+         then
+            # drive and trigger-rates files are needed for analysis
+            #printprocesslog "ERROR "$1" not found."
+            if [ $filenight -le $checknight ] 
+            then 
+               printprocesslog "ERROR "$1" not found."
+            else
+               printprocesslog "WARN "$1" not found."
+            fi
+         else
+            # other aux-files would be good to have
+            #printprocesslog "WARN "$1" not found."
+            if [ $filenight -le $checknight ] 
+            then 
+               printprocesslog "WARN "$1" not found."
+            else
+               printprocesslog "INFO "$1" not found."
+            fi
+         fi
+      fi
+      return 1
+   fi
+   
+   # file available 
+   return 0
+}
+
