Automic Workload Automation

  • 1.  Create static VARA if it does not already exist

    Posted Dec 12, 2017 06:34 AM
    Here’s a JOBI I wrote to create a static VARA object if it does not already exist. It works like a function. Its inputs are the four variables at the top.

    UC4.CREATE_STATIC_VARA.JOBI

    :PRINT "--- BEGIN JOBI --- UC4.CREATE_STATIC_VARA.JOBI"
    ! Set variables to their current values. This avoids a runtime error if they have not already been set.
    :SET &Static_VARA_Name# = &Static_VARA_Name#
    :SET &Static_VARA_Path# = &Static_VARA_Path#
    :SET &Static_VARA_Title# = &Static_VARA_Title#
    :SET &Static_VARA_Overwrite# = &Static_VARA_Overwrite#
    :SET &Validate_Name# = "NO"
    :SET &Validate_Path# = "NO"
    :PRINT "Checking task status to determine the active scripting tab."
    :SET &Task_Status# = GET_UC_OBJECT_STATUS()
    :PRINT "Task status: &Task_Status#"
    :IF &Task_Status# < 1573
    :  SET &Active_Tab# = "pre-process or process"
    :ELSE
    :  SET &Active_Tab# = "post-process"
    :ENDIF
    :PRINT "JOBI running in &Active_Tab# tab."
    :SET &Task_Prefix# = STR_CUT(&$NAME#,1,3)
    :PRINT "Task prefix: &Task_Prefix#"
    :PRINT "Testing required input variables for JOBI."
    :IF &Static_VARA_Name# = "" OR " "
    :  PRINT "ERROR: Input variable &&Static_VARA_Name# is null."
    :  IF &Active_Tab# = "post-process"
    :    MODIFY_STATE RETCODE=8
    :    MODIFY_STATE STATUS_TEXT="JOBI input variable is null."
    :  ELSE
    :    STOP MSG,51,"JOBI input variable is null."
    :  ENDIF
    :ELSE
    :  PRINT "&&Static_VARA_Name# : &Static_VARA_Name#"
    :  IF &Validate_Name# = "YES" or "yes" or "Y" or "y" or "Yes"
    :    SET &VARA_Prefix# = STR_CUT(&Static_VARA_Name#,1,4)
    :    IF &VARA_Prefix# <> "&Task_Prefix#."
    :      PRINT "ERROR: VARA name '&Static_VARA_Name#' does not begin with '&Task_Prefix#.'."
    :      IF &Active_Tab# = "post-process"
    :        MODIFY_STATE RETCODE=8
    :      ELSE
    :        STOP MSG,51,"Invalid VARA name."
    :        MODIFY_STATE STATUS_TEXT="Invalid VARA name."
    :      ENDIF
    :    ENDIF
    :  ENDIF
    :ENDIF
    :IF &Static_VARA_Path# = "" OR " "
    :  PRINT "ERROR: Input variable &&Static_VARA_Path# is null."
    :  IF &Active_Tab# = "post-process"
    :    MODIFY_STATE RETCODE=8
    :    MODIFY_STATE STATUS_TEXT="JOBI input variable is null."
    :  ELSE
    :    STOP MSG,51,"JOBI input variable is null."
    :  ENDIF
    :ELSE
    :  PRINT "&&Static_VARA_Path# : &Static_VARA_Path#"
    :  IF &Validate_Path# = "YES" or "yes" or "Y" or "y" or "Yes"
    :    SET &Path_Prefix# = STR_CUT(&Static_VARA_Path#,1,9)
    :    IF "&Path_Prefix#" <> "/APPS/&Task_Prefix#"
    :      PRINT "ERROR: Path '&Path_Prefix#' does not begin with '/APPS/&Task_Prefix#'."
    :      IF &Active_Tab# = "post-process"
    :        MODIFY_STATE RETCODE=8
    :      ELSE
    :        STOP MSG,51,"Invalid target path."
    :        MODIFY_STATE STATUS_TEXT="Invalid target path."
    :      ENDIF
    :    ENDIF
    :  ENDIF
    :ENDIF
    :SET &Static_VARA_Already_Exists# = ""
    :PRINT "Checking whether object &Static_VARA_Name# already exists."
    :SET &OBJ_ID# = GET_OH_IDNR(&Static_VARA_Name#)
    :IF &OBJ_ID# = "0"
    !  Object does not exist.
    :  PRINT "Object &Static_VARA_Name# does not exist."
    :  SET &Static_VARA_Already_Exists# = "NO"
    :ELSE
    !  Object exists.
    :  PRINT "Object &Static_VARA_Name# already exists."
    :  PRINT "Checking whether &Static_VARA_Name# is a VARA object."
    :  SET &OBJ_TYPE# = GET_OBJECT_TYPE(&Static_VARA_Name#)
    :  IF &OBJ_TYPE# <> "VARA"
    :    PRINT "ERROR: Object &Static_VARA_Name# exists, but is NOT of type VARA."
    :    IF &Active_Tab# = "post-process"
    :      MODIFY_STATE RETCODE=8
    :    ELSE
    :      STOP MSG,51,"Object type mismatch."
    :      MODIFY_STATE STATUS_TEXT="Object type mismatch."
    :    ENDIF
    :  ELSE
    :    PRINT "Object &Static_VARA_Name# is of type VARA."
    :    SET &Static_VARA_Already_Exists# = "YES"
    :  ENDIF
    :ENDIF
    :IF &Static_VARA_Already_Exists# = "YES"
    :  IF &Static_VARA_Overwrite# = "YES" or "yes" or "Y" or "y" or "Yes"
    :    PRINT "&&Static_VARA_Overwrite# is set to YES. Removing existing VARA &Static_VARA_Name#"
    :    SET &RC# = REMOVE_OBJECT(&Static_VARA_Name#)
    :    IF &RC# <> 0
    :      PRINT "ERROR: Could not remove existing VARA &Static_VARA_Name#"
    :      IF &Active_Tab# = "post-process"
    :        MODIFY_STATE RETCODE=8
    :        MODIFY_STATE STATUS_TEXT="REMOVE_OBJECT RC: &RC#"
    :      ELSE
    :        STOP MSG,51,"REMOVE_OBJECT RC: &RC#"
    :      ENDIF
    :    ELSE
    :      SET &Create_VARA# = "YES"
    :    ENDIF
    :  ENDIF
    :ELSE
    :  SET &Create_VARA# = "YES"
    :ENDIF
    :IF &Create_VARA# = "YES"
    :  PRINT "Creating VARA object &Static_VARA_Name# in folder &Static_VARA_Path#."
    :  SET &RC#= CREATE_OBJECT(VARA,&Static_VARA_Name#,&Static_VARA_Path#,&Static_VARA_Title#,"I","C","FREE")
    :  IF &RC# <> 0
    :    SET &RC# = FORMAT(&RC#)
    :    PRINT "ERROR: RC &RC# when attempting to create object &Static_VARA_Name#."
    :    IF &Active_Tab# = "post-process"
    :      MODIFY_STATE RETCODE=8
    :      MODIFY_STATE STATUS_TEXT="CREATE_OBJECT RC: &RC#"
    :    ELSE
    :      STOP MSG,51,"CREATE_OBJECT RC: &RC#"
    :    ENDIF
    :  ELSE
    :    PRINT "Successfully created object &Static_VARA_Name#."
    :    SET &Static_VARA_Created# = "YES"
    :  ENDIF
    :ENDIF
    :PRINT "--- END JOBI ---  UC4.CREATE_STATIC_VARA.JOBI"
    To use the JOBI, simply set the four input variables and run it using an :INCLUDE statement:
    :SET &Static_VARA_Name# = "UC0.TEMP.VARA_STATIC"
    :SET &Static_VARA_Path# = "/APPS/UC0/MAL"
    :SET &Static_VARA_Title# = "Temporary VARA."
    :SET &Static_VARA_Overwrite# = "YES"
    :INCLUDE UC0.CREATE_STATIC_VARA.JOBI
    The script output will look something like this:
    U00020408 --- BEGIN JOBI --- UC4.CREATE_STATIC_VARA.JOBI
    U00020408 Checking task status to determine the active scripting tab.
    U00020408 Task status: 1900
    U00020408 JOBI running in post-process tab.
    U00020408 Testing required input variables for JOBI.
    U00020408 &Static_VARA_Name# :
    UC0.TEMP.VARA_STATIC
    U00020408 &Static_VARA_Path# : /APPS/UC0 
    U00020408 Checking whether object
    UC0.TEMP.VARA_STATIC already exists.
    U00020408 Object UC0.TEMP.VARA_STATIC already exists.
    U00020408 Checking whether UC0.TEMP.VARA_STATIC is a VARA object.
    U00020408 Object UC0.TEMP.VARA_STATIC is of type VARA.
    U00020408 &Static_VARA_Overwrite# is set to YES. Removing existing VARA UC0.TEMP.VARA_STATIC
    U00020646 User ('TESTUSER/DEV') removed object 'UC0.TEMP.VARA_STATIC' via script.
    U00020408 Creating VARA object UC0.TEMP.VARA_STATIC in folder /APPS/UC0.
    U00020647 Object 'UC0.TEMP.VARA_STATIC' was created by script from user: ('TESTUSER/DEV').
    U00020408 Successfully created object UC0.TEMP.VARA_STATIC.
    U00020408 --- END JOBI ---  UC4.CREATE_STATIC_VARA.JOBI
    I use this JOBI object any time I need to create a VARA object that may or may not already exist.

    Enjoy!


  • 2.  Create static VARA if it does not already exist

    Posted Dec 12, 2017 06:42 AM
    We use a similar technique creating Workflow-VARAs for every "Main"- Workflow where Settings, Run-IDs, FilePaths, etc will be stored.
    At the end of our TOP Workflow these Variables will be exported as CSV and deleted.


  • 3.  Create static VARA if it does not already exist

    Posted Jan 15, 2018 08:01 AM
    I updated the JOBI in the original post so that it is context-aware. This allows it to be included in the pre-process or process scripting tab as well, not just the post-process tab.


  • 4.  Create static VARA if it does not already exist

    Posted Jan 15, 2018 08:34 AM
    Note: I use this JOBI in another solution of mine that creates static VARA objects based on the results of SQL queries.


  • 5.  Create static VARA if it does not already exist

    Posted Jan 16, 2018 09:11 AM

    I updated the JOBI again to add optional validation of the name and path of the target VARA object. To enable these validations, just set one or both of these variables to "YES":

    :SET &Validate_Name# = "NO"
    :SET &Validate_Path# = "NO"

    In our environment, the first three characters of the every AE object are the application prefix.This is a three-character identifier used by application teams to identify their AE objects. Users are allowed to create objects only if the object names begin with the application prefix and are located under a particular folder dedicated to that application prefix. This is enforced with user group-level authorizations. So the additional validations here are just a convenience.

    • If &Validate_Name# is set to YES, then the target VARA name begin with PFX..
    • If &Validate_Path# is set to YES, then the target path must begin with /APPS/PFX.

    In both cases, PFX represents the application prefix.

    You can a adjust these validation steps to suit your needs.



  • 6.  Create static VARA if it does not already exist

    Posted Jan 16, 2018 10:05 AM
    Just a general hint for creation of dynamic VARAs:

    * We have only one root folder for dynamic VARAs called DYN_VARA/[application or deparment]/[subfolder]
    * we differ between static (e.g. Config-) and dynamic VARAs by naming them VARS.... (S=Static) or VARA.... (A=dynamic)
    * Dynamic VARAs must have their Creator (Name and Runid) in Name or Title to identify, timestamp is optional but recommended.

    cheers, Wolfgang


  • 7.  Create static VARA if it does not already exist

    Posted Jan 16, 2018 10:08 AM
    We let folks put their objects wherever they like, as long as it’s under their application prefix’s folder. We recommend that they follow a naming convention, but we do not enforce it beyond the first 4 characters.