Automic Workload Automation

Expand all | Collapse all

If endif statement

  • 1.  If endif statement

    Posted Sep 12, 2018 11:18 AM

    !This include statement will be added to the post process tab of all nightly unix
    !batch jobs. It pulls the "TIME" and if the time is between 18:00 hours and
    !24:00 hours or between 00:00 and 0600 hours it will send an email for any
    !critical unix jobs that have failed. Some unix jobs run during day batch and
    !we do not want an email sent to as we are monitoring the day batch.

     

    :SET &TIME# = SYS_TIME()
    :PRINT "Time &TIME#"

    :SWITCH "Y"
    : CASE &TIME# between 180000 and 240000
    : CASE &TIME# between 000001 and 060000
    : SET &CODERETURN# = GET_STATISTIC_DETAIL(,RETURN_CODE)
    : PRINT &CODERETURN#
    : IF &CODERETURN# <> "0"
    : SET &ACTOBJ = ACTIVATE_UC_OBJECT(JOBS,SMART_EMAIL_JOBNAME.CRITICAL_JOBS)
    : ENDIF
    :ENDSWITCH

     

    I have some jobs that don't start because of missing variables or whatever the case may be.  These jobs I don't believe have an error code so they are not caught by the script above.  When they don't start they get an "FAULT_OTHER - Start impossible. Other error."  I need to capture this in the script.  Does the below look correct, I have just added the BOLD.

     

    :SET &TIME# = SYS_TIME()
    :PRINT "Time &TIME#"

    :SWITCH "Y"
    : CASE &TIME# between 180000 and 240000
    : CASE &TIME# between 000001 and 060000
    : SET &CODERETURN# = GET_STATISTIC_DETAIL(,RETURN_CODE)
    : PRINT &CODERETURN#
    : IF &CODERETURN# <> "0" 
    : SET &ACTOBJ = ACTIVATE_UC_OBJECT(JOBS,SMART_EMAIL_JOBNAME.CRITICAL_JOBS)
    : ENDIF
    :ENDSWITCH

    : SET &CODERETURN2# = GET_STATISTIC_DETAIL(,STATUS)
    : PRINT &CODERETURN2#
    : IF &CODERETURN2# = "FAULT_OTHER" 
    : SET &ACTOBJ = ACTIVATE_UC_OBJECT(JOBS,SMART_EMAIL_JOBNAME.CRITICAL_JOBS)
    : ENDIF
    :ENDSWITCH



  • 2.  Re: If endif statement

    Posted Sep 12, 2018 11:46 AM

    FAULT_OTHER has the return code of 1820.

     

    However, I believe that the issue you are running into is if a job fails with FAULT_OTHER it will not generate and run the Post Process.

     

    So, regardless of what is in the post process it will not run if the job errors with FAULT_OTHER



  • 3.  Re: If endif statement

    Posted Sep 12, 2018 11:56 AM
      |   view attached

    Wow, sometimes I wonder what I am thinking.  So what can I do to capture these jobs that don’t start and get a notification out?

     

    Jeff



  • 4.  Re: If endif statement

    Posted Sep 12, 2018 12:01 PM

    I would look at what kicks off the UNIX job. Schedules and JOBP's both have places to evaluate individual sub tasks.



  • 5.  Re: If endif statement

    Posted Sep 12, 2018 12:01 PM

    There should be a few options available to handle this...

     

    Are you kicking off these jobs via a schedule?  If so, you can catch them by invoking something from the schedule's Attributes tab.  

    Are you invoking these jobs via a workflow?  If so, then you can catch them from the workflow's Attributes tab, or via the task's Postconditions, or via a successor's Dependencies.



  • 6.  Re: If endif statement

    Posted Sep 12, 2018 12:26 PM
      |   view attached

    They are part of a workflow.  You mention the “task’s Postconditions”.  If the job doesn’t start it doesn’t read that does it or is postconditions different than post process tab?  Where do I find the postconditions of a job?



  • 7.  Re: If endif statement

    Posted Sep 12, 2018 02:04 PM

    If you do a right-click -> 'Task Properties' on the job in the workflow there will be a tab called Post Conditions. This is different than the post process.



  • 8.  Re: If endif statement

    Posted Sep 12, 2018 02:30 PM
      |   view attached

    Perfect, I see that now.  I will work with this.

     

    Thanks so much for your help,

     

    Jeff



  • 9.  Re: If endif statement

    Posted Oct 12, 2018 03:35 PM

    Hi JeffMuller608908,

    Were you able to resolve the issue you had? If so, do you mind sharing with the community what the cause of it was.  Additionally, if any of the suggest provided by Michael or Daryl help in resolving your issue, please help us use the "Mark Correct" button on the comment that answered your questions.



  • 10.  Re: If endif statement

    Posted Oct 12, 2018 03:47 PM
      |   view attached

    I have been busy with other things.  Sorry, I have not resolved this.  If I do, I will update you.

     

    Jeff



  • 11.  Re: If endif statement

    Posted Oct 15, 2018 08:30 AM

    Hello Jeff,

     

    I wounder how this code could work with just one :SWITCH but two :ENDSWITCH statements. Is this the exact code you use in the include or did I miss something?

     

     

    Regards

    Matthias



  • 12.  Re: If endif statement

    Posted Oct 15, 2018 12:30 PM

    I never did add the part in bold.  Michael Pirson , above lets me know the reason it will not work.  



  • 13.  Re: If endif statement

    Posted Oct 16, 2018 04:34 AM

    Ahhh I see. Sorry misread that.

     

    So, did you try what Michael or Daryl suggested? You could add a call Object right behind the Job you'd like to monitore or just add a call object to the workflow the job is running in. This will also catch FAULT_OTHER errors.

     

    Here's where to put the CALL Object:

     

     

    Regards, Matthias



  • 14.  Re: If endif statement
    Best Answer

    Posted Oct 17, 2018 11:19 AM

    I was trying to remember what we did here.  The job in question was part of a workflow.  I ended up putting a longest run time on the workflow so if there was a failure it would be caught but the longest runtime and an email sent out.  I do like Michael idea.  The reason I went with the longest runtime is that many of our jobs and process flows already have longest runtimes.  I may try his suggestion in the future though.