› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Advanced Scheduling with FTP protocol
Thanks.
If you’d like, I could post the code of the proc I created.
can you post the code for the proc you created. thanks
This has seemed to run pretty well since I set it up a year ago. It doesn’t look for the file when run mode is executed right after the process is bounced, but it does look for the file when advanced scheduling kicks it off afterwards.
######################################################################
# Name: tps_local_midas_drg
# Purpose: select the file in the local directory to process
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (”start”, “run” or “test”)
# MSGID message handle
# ARGS user-supplied arguments:
#
#
# Returns: tps disposition list:
# Returns a list of messages for the fileset
# driver to process.
#
# Note: there appears to be a bug current in 5.4 in that when the
# thread or process is started, this dirParse proc is run twice, once
# in ‘start’ mode and then again in ‘run’ mode. I have put a fix in
# place using a global flag variable, so that the first ‘run’ after a
# startup will skip most actions in the run mode section. The actions
# will execute on a subsequent run triggered by advanced scheduling.
proc tps_local_midas_drg { args } {
global midas_drg_startup
keylget args MODE mode
set proc_name [lindex [info level [info level]] 0]
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
# set flag to indicate process/thread startup.
set midas_drg_startup “1”
return {}
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
# Check for correct context
keylget args CONTEXT ctx
if {![cequal $ctx “fileset_ibdirparse”]} {
echo “ERROR proc used in wrong context”
echo “Context should be fileset_ibdirparse”
echo “Proc called in: $ctx”
return “{CONTINUE $mh}”
}
# check for startup flag and set off if this is the first run after start.
if {[cequal $midas_drg_startup “1”]} {
set midas_drg_startup “0”
msgset $mh {}
} else {
# all other actions in run mode occur only during a scheduled run, not startup run.
# In this context the message handed to this proc
# by the driver in not a data message. Rather
# it is a space separated string of file names
# from the directory the fileset driver is
# configured to read.
# I am expecting this directory to contain a single instance of file “MDSDRG”,
# and if it’s not there I want to raise a stink about it.
set msg_list [msgget $mh]
set msg_list [split $msg_list]
set msg_list [lregexp $msg_list “^MDSDRG$”]
if {[llength $msg_list] != 0} {
echo “***n*** $proc_name – found file to process: $msg_list n***”
set emails “MDSDRG”
set subject “_SUCCESS_ – Midas DRG/Charges Interface File”
set message “File MDSDRG was found and will be processed.”
set filePath “/quovadx/ftptransfers/MDSDRG/MDSDRG”
set fileSize [file size $filePath]
set fileDate [clock format [file mtime $filePath] -format %Y%m%d]
set todayDate [clock format [clock seconds] -format %Y%m%d]
if {(![cequal $fileDate $todayDate]) || ($fileSize == 0)} {
set subject “_WARNING_ – Midas DRG/Charges Interface File”
set message “File MDSDRG was zero-length or not today’s date.”
}
} else {
echo “***n*** $proc_name – NO MDSDRG FILE FOUND TO PROCESS n***”
set emails “MDSDRG_ERR”
set subject “_ERROR_ – Midas DRG/Charges Interface File”
set message “File MDSDRG has not been transfered from the mainframe!nnPage the PAB DO.”
}
alertTrigger “$emails” “$subject” “n$message” “gemini.mmc.org” “mmc.org” “” “”
msgset $mh $msg_list
}
return “{CONTINUE $mh}”
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
echo “*** $proc_name shutting down.”
}
default {
error “Unknown mode ‘$mode’ in $proc_name”
}
}
}
Of course some of this proc is specific to our site and this particular file, but you should be able to just swap in your runtime actions in the section after:
} else {
# all other actions…
I also don’t know if this unfortunate quovadx behaviour of executing both Start and Run modes after a process bounce remains consistant in releases before or after 5.4, so caveat emptor, etc.
Greg E.