Automic Workload Automation

  • 1.  Need help scripting a job

    Posted Feb 09, 2018 01:53 PM
    I have a job that runs weekly on Tuesdays. It is using a modified run control to update the current date into the run control in Peoplesoft. My problem is that on the last Tuesday of any month, instead of populating the current date, the date needs to change to the first date of the following month. Any ideas on how to code that in Automic? 


  • 2.  Need help scripting a job
    Best Answer

    Posted Feb 09, 2018 03:00 PM
    Nailed it.  (I love date challenges!)
    Note that you can change the "20180424" literal to test for different run days.
    ==========




    ! return current date on Tuesdays, except for last Tuesday of month.

    :Set &MyFormat# = "YYYYMMDD"

    !:set &Today# = sys_date_physical(&MyFormat#)
    :set &Today# = "20180424"
    :print "today: &Today#"

    :set &MM# = substr(&Today#,5,2)
    :print "Current MM: &MM#"

    !Test to see if next tuesday is in the same month
    :set &NextWeek# = add_days("&MyFormat#:&Today#",7)
    :set &NextWeekMM# = substr(&NextWeek#,5,2)
    :print "NextWeekMM: &NextWeekMM#"
    :if &NextWeekMM# = &MM#
    :   print "No adjustment necessary"
    :   set &Results# = &Today#
    :else
    :     print "Adjusting date to first of next month"
    :  set &Results# = last_of_period("&MyFormat#:&Today#","MM",&MyFormat#)
    :  set &Results# = add_days("&MyFormat#:&Results#",1)
    :endif

    :print "results: &Results#"


  • 3.  Need help scripting a job

    Posted Feb 11, 2018 09:54 AM
      |   view attached
    Like Date riddles too :-)

    here is an alternative using a CALE object:

    :SET &CALE# = "CALE.COMM.LAST_TUESDAY"
    :SET &CALE_KEYWORD_LAST_TUE# = "ROLL_LAST_TUE"
    :SET &CALE_KEYWORD_1OM# = "MONTHLY_1ST"
    :SET &CALE_KEYWORD_TUE# = "WEEKLY_TUE"
    ! Toggle either sysdate or a select some given dates (LAST TUE, ANY TUE, ANY day)
    !:SET &DATE# = &$PHYS_DATE_YYYYMMDD#
    :SET &DATE# = "20180130"
    !:SET &DATE# = "20180123"
    !:SET &DATE# = "20180124"
    !
    ! ###################### CONFIG END ########################################
    !
    :PRINT "&&DATE#  =  &DATE#"
    !
    :SET &IS_TUE# = VALID_CALE("YYYYMMDD:&DATE#", &CALE#, &CALE_KEYWORD_TUE#)
    :PRINT "&&IS_TUE# = &IS_TUE#"
    !
    ! checking if DATE matches last TUE Keyword within CALE
    :SET &IS_LAST_TUE# = VALID_CALE("YYYYMMDD:&DATE#", &CALE#, &CALE_KEYWORD_LAST_TUE#)
    :PRINT "&&IS_LAST_TUE# = &IS_LAST_TUE#"
    !
    :SET &SWITCHVALUE# = "&IS_TUE#&IS_LAST_TUE#"
    :PRINT "&&SWITCHVALUE# = &SWITCHVALUE#"
    !
    :SWITCH &SWITCHVALUE#
    :  CASE "NN"
    :  PRINT "## ANY DAY"
    :  SET &DATE_to_PROCESS# = ""
    :  CASE "YY"
    :  PRINT "## LAST TUESDAY in month"
    :  SET &DATE_to_PROCESS# = CALE_LOOK_AHEAD(&DATE#, 'ONE', &CALE#, &CALE_KEYWORD_1OM#)
    :  CASE "YN"
    :  PRINT "## ANY TUESDAY"
    :  SET &DATE_to_PROCESS# = &DATE#
    :  CASE "NY"
    :  PRINT "## not possible"
    :  SET &DATE_to_PROCESS# = "ERROR"
    :  OTHER
    :  PRINT "## not possible as well"
    :  SET &DATE_to_PROCESS# = "ERROR"
    :ENDSWITCH
    !
    :PRINT "&&DATE_to_PROCESS# = &DATE_to_PROCESS#"


    Attachment(s)

    xml
    V112_LAST_TUE.xml   2 KB 1 version


  • 4.  Need help scripting a job

    Posted Feb 13, 2018 02:40 PM
    WOW! You guys are both amazing! I'll test our stuff with both of these. Thank you both so much!


  • 5.  Need help scripting a job

    Posted Feb 13, 2018 02:56 PM
    THX and have fun with it :-)