Automic Workload Automation

Expand all | Collapse all

How to determine Task Running Numbers with JCL

  • 1.  How to determine Task Running Numbers with JCL

    Posted Nov 30, 2016 12:18 PM
    Hello,

    Using MODIFY_TASK to make changes to a task in a currently-active workflow requires a running number (different than the RunID).  I can't seem to determine how to poll a work flow to resolve Running Number to a Task Name, or vice versa.

    It's pretty easy to set everything in a workflow inactive for example:

    :  SET &RETSTOP# = MODIFY_TASK(&$ACTIVATOR_RUNID#, STOP_MODIFY)
    :  SET &RETMOD# = 0
    :  SET &TASKNUMBER# = 1
    :  WHILE &RETMOD# <> 0000000000020741
    :    SET &RETMOD# = MODIFY_TASK(&$ACTIVATOR_RUNID#,,&TASKNUMBER#, ACTIVE, "NO")
    :    SET &TASKNUMBER# = 1 + &TASKNUMBER#
    :  ENDWHILE
    :  SET &RETCOMMIT# = MODIFY_TASK(&$ACTIVATOR_RUNID#, COMMIT)
    :  SET &RETGO# = MODIFY_TASK(&$ACTIVATOR_RUNID#, GO)

    (0000000000020741 is the error code that MODIFY_TASK supplies when a given task number doesn't exist in a workflow to be modified.)

    But that's not always what I want to do.    Does anyone know how to turn a Running Number into a Task Name or vice versa?  Ideally, a method that would work on a workflow that's not currently running, but a solution for running flows would solve my current issue.


  • 2.  How to determine Task Running Numbers with JCL

    Posted Dec 02, 2016 05:44 AM
    Hello JamesD.

    You can try using GET_STATISTIC_DETAIL :

    Syntax : GET_STATISTIC_DETAIL([RunID], Detail, [Object name])        

    • Retrieve a task's name from its RunID (in this example, the RunID is retrieved with                     &$RUNID#)
    : SET &NAME# = GET_STATISTIC_DETAIL(&$RUNID#,"NAME",)

    • Retrieve a task's RunID from its name (in the example this job is called "MYJOB")
    : SET &RUNID# = GET_STATISTIC_DETAIL( ,"RUNID","MYJOB")


    Hope this helps.

    Best regards,
    Antoine






  • 3.  How to determine Task Running Numbers with JCL

    Posted Dec 02, 2016 10:08 AM
    Using the RunID would work if there was a way to determine the RunID of every task in the current workflow without knowing the job names.  

    I'm trying to do two things - 

    1) Turn the code in the original post into a job include that can say "If (something), then set every task in the workflow inactive".  The above will work, but it's kinda wonky in that it will set the END object inactive as well.  I could subtract 1 from &TASKNUMBER#, and set that active again, but I might want a more controlled version in the future such as "only set jobs with (something) in the job name inactive".

    2) Make a job that can list every task in a (not running/active) workflow, along with their Running Number.  This information is available when you edit a workflow in the java client or the web interface, but it would be handy to be able to display it outside of that.

    It might be that 2 is impossible to implement in JCL, as I've not found a way to do anything like that to workflows that aren't running.


  • 4.  How to determine Task Running Numbers with JCL

    Posted Dec 02, 2016 07:48 PM
    I think there's a little confusion on terms here, you mention JCL but it sounds like you're talking about AE Scripting. JCL is the unix/windows/etc. commands sent to the agent.

    I don't think you can do this with just AE script, but you can if you use a SQLI vara to query the database for a list of active jobs. This query would list all active jobs along with the info you might want:

    select EH_Client, EH_Name, EH_ah_Idnr, EH_ParentAct, EH_ParentPrc from EH

    You could then use prep_process_var() to filter down to just the children of the workflow you're interested in.

    Unfortunately subflows would not directly show their top workflow parent, for that you'd need a recursive query, or you could call sys_act_top_nr() on each runid (probably slow if you have a very active system).


  • 5.  How to determine Task Running Numbers with JCL

    Posted Dec 03, 2016 11:29 AM
    You can use prep_process_report and parse the activation report - here you will get a complete List of all Jobs and Run IDs within the Workflow.
    This does not work for conditions....

    [EDIT] Sorry, does not work within the Script (Activation) of the Workflow itself.

    Wht do you want to archieve? Could you give us a bigger view what you want to do?


  • 6.  How to determine Task Running Numbers with JCL

    Posted Dec 05, 2016 11:18 AM
    Mark - Sorry, we've been calling the whole thing JCL up till now.

    There are two things I would like to achieve:

    1) Make a job include that can be added to tasks in different workflows so that if some condition is met, the rest of the tasks, or some subset of the tasks, in the workflow is set inactive.

    2) I'd like to be able to list all of the tasks in a workflow that is not currently active, and the "running number" of each of those tasks.  

    3) I'm completely unfamiliar with SQL, so I'm hesitant to go in that direction.  I'll learn it if it's the only way, though.

    Part of our issue is that our team won't be the only team with access to the tool in production.  We can't have people changing jobs on their own, but there's no way to separate "can change what a job does" and "is this job active" with user permissions - currently, we have a java-based solution in place to do this, but it would be more ideal to have this handled via AE Scripting.

    Also, we're looking at creating a job to handle moving objects between environments, so being able to list what's in a non-running workflow would be very helpful.

    I do appreciate you taking the time to answer my questions!


  • 7.  How to determine Task Running Numbers with JCL

    Posted Dec 05, 2016 01:46 PM
    James:

    As Wolfgang_Bauer_7247 indicated you can use a PREP_PROCESS_REPORT against the workflow's Activation report to see the object names that have been activated.  You can then, assuming that an object is not used more than once (it is unique within the workflow), use the object's name to perform the MODIFY_TASK function.   You would only need to supply the running number when that task exists multiple times in the workflow.

    As the documentation states:

    Name or running number of the workflow task that should be replaced.
    Format: script literal, number or script variable. Within a workflow, a task can be identified via its nameor its running number. You can specify the task nameornumber within the workflow. Specifying both parameters requires that the name and the number comply with each other.


    Hope this helps.


  • 8.  How to determine Task Running Numbers with JCL

    Posted Dec 05, 2016 02:52 PM
    JamesD.for 2) could help my SQL Statement here
    https://community.automic.com/discussion/8061/sql-to-extract-processflow-dependancies-from-automation-engine-database#latest

    The "Number" you are probably searching in a NON-running Workflow is the Object number the System assigns automatically when creating the workflow - shown this way (3) or (7)
     
    in my SQL - JPP_LNR as 'OBJ Nr within Workflow'

    => pls give it a try :-)

    for 1) I can give you  code snippets for a general include for any kind of JOBS lets call it "RUN switch"
    in my case its a number entred in a static VARA object - if 1 job runs, if 0 the job remains in state "inactive"
    will look for it tomorrow morning (CET - Morning....) an post it here.



  • 9.  How to determine Task Running Numbers with JCL

    Posted Dec 05, 2016 04:50 PM
    Wolfgang - I'm not very familiar with SQL, but that looks like nearly exactly what I was looking for.  I'll have to read up on SQL a bit, but I'm thinking that will do nicely for 2.  It's definitely the Object number.  I'm not sure why they call it "running number" in the documentation.

    I've actually done the variable table thing for run/skip!  At the time, we were working on a setup to have jobs run or not on the job level, instead of the workflow level.

    It seems strange that there's not a way within the scripting language to match up an object number to a jobname for a given workflow, even if it would only work for active ones.  I might just have to accept it, and use my original idea or the variable table thing.


  • 10.  How to determine Task Running Numbers with JCL
    Best Answer

    Posted Dec 06, 2016 03:09 AM
    James D. said:
    Wolfgang - I'm not very familiar with SQL, but that looks like nearly exactly what I was looking for.  I'll have to read up on SQL a bit, but I'm thinking that will do nicely for 2.  It's definitely the Object number.  I'm not sure why they call it "running number" in the documentation.
    Great :-)

    James D. said:
    It seems strange that there's not a way within the scripting language to match up an object number to a jobname for a given workflow, even if it would only work for active ones.  I might just have to accept it, and use my original idea or the variable table thing.
    To be honest - I have no glue why and what for you want to use this whle the workflow is not running...
    Usually you use the MODIFY_TASK script commands to change an activated workflow according to your needs - so you start lets say an empty "workflow frame" and add tasks and logic via script.
    Or you start the whole workflow with all jobs and use pre(or post)Conditions and MODIFY_TASK to set the jobs inactive.

    But as long as this solution works as you wish ....... :-)