Automic Workload Automation

  • 1.  File Event with multiple paths

    Posted May 22, 2014 01:44 AM
    Hello I have a need to fire an event when a directory has received 1 each of x number files.

    The files have differing names with no common pattern (other than the directory) and the file names are all appended with a time stamp.

    Unfortunately it is acceptable for multiple versions of one file (only differing by time stamp) to arrive so a file count doesn't work.

    e.g. I need the event to fire when at least 1 copy of files a.*, b.* and c.* arrive.

    I may already have the following files and am just waiting for 1 copy of c.*

    \a.201420011544
    \a.201420032723
    \a.201420181759
    \b.201421000812

    Obviously I can run a script regularly but was wondering if there is an elegant way to handle in UC4

    Many thanks in advance

     



  • 2.  File Event with multiple paths
    Best Answer

    Posted May 22, 2014 11:19 AM

    Hi Bruce, 

    I do not know a way to solve your use case elegantly without scripting ..

    .. But I consider scripts (Automic or JCL) as often very elegant solutions. :)  (As long as you see them directly from within the UserInerface) ...




  • 3.  File Event with multiple paths

    Posted Jun 04, 2014 11:04 AM

    Some ideas for you...

    1) Create a workflow with 3 parallel "until first hit" file events -- one looking for a*, one looking for b*, and one looking for c*. The events don't do anything on their respective !Process tabs, but all three would flow into a task (script object?) that would perform the necessary task.  You could run this workflow as a recurring task (e.g., period container).

    2) Similar to #1, but have a separate time event trigger the workflow (i.e,. ACTIVATE_UC_OBJECT) at regular intervals instead of running the workflow as a period container.  (I'd need to test this, but I think you could use the 'WAIT' parameter as part of your ACTIVATE_UC_OBJECT call so that the event does not fire again until after the workflow completes.)

    3) Setup three separate file events, looking for a*, b*, and c*, set to run repeatedly (as opposed to 'until first hit').  On their !Process tab, have them update a variable object to indicate that A/B/C files have been found.  Then build a separate time event where the !Process tab will check this variable object to see if all three file types have been found, and if so, perform/activate the necessary task(s).  Make sure to reset these A/B/C values in your variable object upon completion so that your event doesn't fire multiple times in a row for the same files.



  • 4.  File Event with multiple paths

    Posted Jun 12, 2014 11:00 PM

     

    Thanks for your help folks.  Daryl, your suggestions were good for a small number of file patterns but unfortunately I have some jobs that are looking for over 70 patterns.

     

    In the end I went with a script that enumerates a list of patterns in a variable and looks for a match in the directory.

    This is it below in case anyone is faced with the same problem or would like to critique :)

     

    :PRINT "Searching in &PATH#"
    :SET &FILE_COUNT# = 0
    :SET &FILE_FOUND# = 0

    !Get the list of expected files
    :SET &HND#=PREP_PROCESS_VAR(&FILE_LIST#)

    !Get the list of files in the search directory
    :SET &FILE_HND# = PREP_PROCESS_FILENAME("&HOST#","&PATH#*","Y",,,,"UC_LOGIN=CLIENT_FI.LOGIN.BATCH.ACCOUNT")

    !Loop through the expected files
    :PROCESS &HND#

    :  SET &FILE_COUNT# = ADD(&FILE_COUNT#,1)
    :  SET &VK# = GET_PROCESS_LINE(&HND#,1)
    :  SET &VK# = STR_CAT(&PATH#, &VK#)

    :  PRINT ""
    :  PRINT "Looking for: &VK#"

    !  Loop through the files looking for a match
    :  PROCESS &FILE_HND#
    :     SET &FILE# = GET_PROCESS_LINE(&FILE_HND#,1)

    :     PRINT "   Comparing: &FILE#"

    :     SET &VK# = CONV_UC(&VK#)
    :     SET &FILE# = CONV_UC(&FILE#)

    :     SET &RET# = STR_MATCH(&FILE#, &VK#)

    !     If found increment the counter and exit the loop
    :     IF &RET# = "Y"
    :       SET &FILE_FOUND# = ADD(&FILE_FOUND#,1)
    :       PRINT "Found &FILE#!!!"
    :       TERM_PROCESS
    :     ENDIF
    :  ENDPROCESS

    :ENDPROCESS

    :PRINT "Needed: &FILE_COUNT#  Found &FILE_FOUND#"

    :IF &FILE_COUNT# = &FILE_FOUND#
    :  SET &ACTOBJ# = ACTIVATE_UC_OBJECT(&JOB_TO_EXECUTE#)

    :  IF &ACTOBJ# = "0"
    :    SET &ERRNR# = SYS_LAST_ERR_NR()
    :    SET &ERRINS# = SYS_LAST_ERR_INS()
    :    SET &MESSAGE# = GET_MSG_TXT(&ERRNR#, &ERRINS#)
    :  ENDIF

    !Deactivate this event if this is a single file watch
    :  IF &END_ON_FIRST_HIT# = "Y"
    :    SET &JOBNR# = SYS_ACT_PARENT_NR()
    :    SET &STATUS# = CANCEL_UC_OBJECT(&JOBNR#)
    :  ENDIF

    :ENDIF