Automic Workload Automation

 View Only
  • 1.  Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 02, 2018 01:47 AM

    hi everyone,

     

    I am looking for a solution to the following problem:

    "By default, we only assign prompts to workflows. However, if a JOBS is executed individually in development other than in production, the workflow prompt should be executed first so that all required variables are defined.

     

    My solution was to use SQLI to find out the parent and the prompt and then use :BEGINREAD... :ENDREAD or :READ and run it in the pre-script. However, I now fail because I have the value "TEST#" (variable name in the prompt) in the variable "&PRPT_VARA_NAME#" via PREP_PROCESS_PROMPTSET.

     

    Now, if I ever execute the :READ - command
    ":READ &PRPT_VARA_NAME#, "Input Text"... "the error message
    "Runtime error in object 'SCRI.NEW.CREATE_PRPT', line '00025'. An attempt was made to use a READ statement to set variable '&PRPT_VARA_NAME#' twice within a block READ."

     

    Is there a way to pass the resolved variable "&PRPT_VARA_NAME#" to the :READ command so that during execution " : READ &TEST#, "......" "arrives?

     

    here is the place of my script problem:

    :BEGINREAD "REBUILD Prompt"
    :SET &PPP_PARENT# = PREP_PROCESS_PROMPTSET("PRPT.NEW.JOBP")
    :PROCESS &PPP_PARENT#
    :  SET &LINE# = GET_PROCESS_LINE(&PPP_PARENT#)
    :  P "P-LINE  : &LINE#"
    :  SET &PRPT_VARA_NAME# = GET_PROCESS_LINE(&PPP_PARENT#,1)
    :  SET &PRPT_VARA_DEFAULT# = GET_PROCESS_LINE(&PPP_PARENT#,3)
    :  READ &PRPT_VARA_NAME#, "08", "Please enter Value",&PRPT_VARA_DEFAULT#, M
    :ENDPROCESS
    :CLOSE_PROCESS &PPP_PARENT#
    :ENDREAD

     

     

    #prompts #promptset#:read #promptsetvariables #variablesubstitution



  • 2.  Re: Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 17, 2018 04:00 AM

    Perhaps PREP_PROCESS_PROMPTSET uses :READ internally.



  • 3.  Re: Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 17, 2018 08:38 AM

    I did a bit of testing, and I don't think what you are trying to do will work, for a couple of reasons:

    1. The PREP_PROCESS_PROMPTSET command does not appear to work inside a :BEGINREAD...:ENDREAD block. It simply creates an empty data sequence.
    2. What you’re trying to do is to read in a bunch of variables whose names are read from the prompt set. However, this would require a variant of the :READ command that can read in the value of the variable using indirect reference., like :SET_SCRIPT_VAR does. The :READ command does not work this way. It takes as its first argument the exact name of the variable to set, not the name of a variable that contains the name of the variable to set.

     

     



  • 4.  Re: Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 17, 2018 12:20 PM
      |   view attached

    Ok, I figured out a way to do what you are trying to do. Here’s how I worked around the two problems:

    1. I moved the :BEGINREAD and :ENDREAD statements inside the :PREP_PROCESS_PROMPTSET loop. It seems weird, but it works.
    2. I hard-coded all of the possible prompt set variable names in a :SWITCH block. This is not very elegant, but again, it works.

     

    Consider the following sample prompt set.

     

    The script that parses the prompt set looks like this:

    :SET &Verbose_mode# = "YES"
    :SET &PromptSet_Name# = "UC0.PROMPT_SET-TEST2.PRPT"
    :SET &PPP_Hnd# = PREP_PROCESS_PROMPTSET("&PromptSet_Name#")
    :SET &NumColumns# = GET_PROCESS_INFO(&PPP_Hnd#,COLUMNS)
    :SET &NumRows# = GET_PROCESS_INFO(&PPP_Hnd#,ROWS)
    :IF &NumRows# > 0
    :  SET &NumColumns# = GET_PROCESS_INFO(&PPP_Hnd#,COLUMNS)
    :ELSE
    :  SET &NumColumns# = 0
    :ENDIF
    :SET &Counter# = 0
    :PROCESS &PPP_Hnd#
    :  SET &Counter# = &Counter# + 1
    !  If this is the first element in the prompt set, begin the READ block.
    :  IF &Counter# = 1
    :    BEGINREAD
    :  ENDIF
    :  SET &PromptSet_Element_Variable#    = GET_PROCESS_LINE(&PPP_Hnd#,1)
    :  SET &PromptSet_Element_CustomField# = GET_PROCESS_LINE(&PPP_Hnd#,2)
    :  SET &PromptSet_Element_Default#     = GET_PROCESS_LINE(&PPP_Hnd#,3)
    :  SET &PromptSet_Element_Type#        = GET_PROCESS_LINE(&PPP_Hnd#,4)
    :  SET &PromptSet_Element_DataSource#  = GET_PROCESS_LINE(&PPP_Hnd#,5)
    :  SET &PromptSet_Element_Key#         = GET_PROCESS_LINE(&PPP_Hnd#,6)
    :  SET &VarName# = STR_CUT(&PromptSet_Element_Variable#,1)
    :  SET &Caption# = &PromptSet_Element_CustomField#
    :  SET &Default# = &PromptSet_Element_Default#
    :  RESOLVE &Default# = "&Default#"
    :  IF &Verbose_mode# = "YES"
    :    PRINT "Prompt set element details:"
    :    PRINT "Variable name      : &&&PromptSet_Element_Variable#"
    :    PRINT "Custom field       : &PromptSet_Element_CustomField#"
    :    PRINT "Default value      : &PromptSet_Element_Default#"
    :    PRINT "Element type       : &PromptSet_Element_Type#"
    :    PRINT "Data source        : &PromptSet_Element_DataSource#"
    :    PRINT "Key                : &PromptSet_Element_Key#"
    :    PRINT "Variable name without leading ampersand (&&): &VarName#"
    :    PRINT "Resolving variables in default value."
    :    PRINT "Resolved default: &Default#"
    :  ENDIF
    :  SET &InputCheck# = ""
    :  SWITCH &PromptSet_Element_Type#
    :  CASE "label"
    :    PRINT &Default#
    :  CASE "integer"
    :    PRINT "Number fields not handled yet."
    :  CASE "text"
    :  CASE "combo"
    !    Assemble list of possible values from element data source.
    :    SET &DS_Hnd# = PREP_PROCESS_VAR(&PromptSet_Element_DataSource#)
    :    PROCESS &DS_Hnd#
    :      SET &DS_Value# = GET_PROCESS_LINE(&DS_Hnd#,1)
    :      SET &InputCheck# = "&InputCheck#,&DS_Value#"
    :    ENDPROCESS
    :    CLOSE_PROCESS &DS_Hnd#
    :  CASE "dynradiogroup"
    :    PRINT "Radio button groups not handled yet."
    :  CASE "dyncheckgroup"
    :    PRINT "Check box groups not handled yet."
    :  CASE "time"
    :    PRINT "Time fields not handled yet."
    :  CASE "datefield"
    :    PRINT "Date fields not handled yet."
    :  CASE "timestamp"
    :    PRINT "Timestamp fields not handled yet."
    :  ENDSWITCH
    !  Because the :READ command accepts only specific variable names as the first arugment,
    !  the names of all of the prompt set variables that might be encountered must be
    !  hard-coded here, each with its own CASE clause in the SWITCH...ENDSWITCH block.
    :  SWITCH &VarName#
    :  CASE "TEXTFIELD1#"
    :    READ &TEXTFIELD1#, &InputCheck# , &Caption#, &Default#
    :  CASE "COMBOBOX1#"
    :    READ &COMBOBOX1#, &InputCheck#, &Caption#, &Default#
    :  ENDSWITCH
    :  PRINT
    !  If this is the last element in the prompt set, end the READ block.
    :  IF &Counter# = &NumRows#
    :    ENDREAD
    :  ENDIF
    :ENDPROCESS
    :CLOSE_PROCESS &PPP_Hnd#

     

    When the script is run (without Generate at runtime enabled), the prompt set is re-created almost perfectly.

    Note that the script even performs a couple of extra steps:

    • It recreates the pick list for the combo box, based on the data source for the element specified in the prompt set; and
    • It resolves variables & VARA references in the default values.

     

    While playing around with this, I discovered that inside a :BEGINREAD...:ENDREAD block, all :PRINT statements are treated as labels. (Set &Verbose_mode# to "YES" to see a demonstration of this.)

    Attachment(s)



  • 5.  Re: Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 17, 2018 12:30 PM
      |   view attached

    Here is an updated version that handles all prompt set element types. I’ve put it in a JOBI to make it easy to re-use.

     

    UC0.PREP_PROCES_PROMPTSET.JOBI

    :PRINT "--- BEGIN UC0.PREP_PROCES_PROMPTSET.JOBI ---"
    :SET &PPP_Hnd# = PREP_PROCESS_PROMPTSET("&PromptSet_Name#")
    :SET &NumColumns# = GET_PROCESS_INFO(&PPP_Hnd#,COLUMNS)
    :SET &NumRows# = GET_PROCESS_INFO(&PPP_Hnd#,ROWS)
    :SET &Verbose_mode# = &Verbose_mode#
    :SET &Obscure_text_input# = &Obscure_text_input#
    :IF &NumRows# > 0
    :  SET &NumColumns# = GET_PROCESS_INFO(&PPP_Hnd#,COLUMNS)
    :ELSE
    :  SET &NumColumns# = 0
    :ENDIF
    :SET &Counter# = 0
    :PROCESS &PPP_Hnd#
    :  SET &Counter# = &Counter# + 1
    !  If this is the first element in the prompt set, begin the READ block.
    :  IF &Counter# = 1
    :    BEGINREAD
    :  ENDIF
    :  SET &PromptSet_Element_Variable#    = GET_PROCESS_LINE(&PPP_Hnd#,1)
    :  SET &PromptSet_Element_CustomField# = GET_PROCESS_LINE(&PPP_Hnd#,2)
    :  SET &PromptSet_Element_Default#     = GET_PROCESS_LINE(&PPP_Hnd#,3)
    :  SET &PromptSet_Element_Type#        = GET_PROCESS_LINE(&PPP_Hnd#,4)
    :  SET &PromptSet_Element_DataSource#  = GET_PROCESS_LINE(&PPP_Hnd#,5)
    :  SET &PromptSet_Element_Key#         = GET_PROCESS_LINE(&PPP_Hnd#,6)
    :  SET &VarName# = STR_CUT(&PromptSet_Element_Variable#,1)
    :  SET &Caption# = &PromptSet_Element_CustomField#
    :  SET &Default# = &PromptSet_Element_Default#
    :  IF &PromptSet_Element_Type# <> "label"
    :    RESOLVE &Default# = "&Default#"
    :  ENDIF
    :  IF &Verbose_mode# = "YES"
    :    PRINT "Prompt set element details:"
    :    PRINT "Variable name      : &&&PromptSet_Element_Variable#"
    :    PRINT "Custom field       : &PromptSet_Element_CustomField#"
    :    PRINT "Default value      : &PromptSet_Element_Default#"
    :    PRINT "Element type       : &PromptSet_Element_Type#"
    :    PRINT "Data source        : &PromptSet_Element_DataSource#"
    :    PRINT "Key                : &PromptSet_Element_Key#"
    :    PRINT "Variable name without leading ampersand (&&): &VarName#"
    :    PRINT "Resolving variables in default value."
    :    PRINT "Resolved default: &Default#"
    :  ENDIF
    :  SET &InputCheck# = ""
    :  SET &InputHandling# = ""
    :  SWITCH &PromptSet_Element_Type#
    :  CASE "label"
    :    SET &Build_InputCheck_String# = "NO"
    :    PRINT "&Default#"
    :  CASE "integer"
    :    SET &Build_InputCheck_String# = "NO"
    :    SET &InputHandling# = "&InputHandling#N"
    :  CASE "text"
    :    SET &Build_InputCheck_String# = "NO"
    :    SET &InputHandling# = "&InputHandling#K"
    :    IF &Obscure_text_input# = "YES"
    :      SET &InputHandling# = "&InputHandling#D"
    :    ENDIF
    :  CASE "combo"
    :    SET &Build_InputCheck_String# = "YES"
    :    SET &Column_To_Read# = 1
    :    SET &InputHandling# = "&InputHandling#O"
    :  CASE "dynradiogroup"
    :    SET &Build_InputCheck_String# = "YES"
    :    SET &Column_To_Read# = 2
    :  CASE "dyncheckgroup"
    :    PRINT "Because check box groups are recreated here as combo boxes, it is possible to select only one value."
    :    SET &Build_InputCheck_String# = "YES"
    :    SET &Column_To_Read# = 2
    :  CASE "time"
    :    PRINT "Please enter a time in HH:MM format (24-hour clock)."
    :    SET &Build_InputCheck_String# = "NO"
    :  CASE "datefield"
    :    PRINT "Please enter a date in YYYY-MM-DD format."
    :    SET &Build_InputCheck_String# = "NO"
    :  CASE "timestamp"
    :    PRINT "Please enter a time stamp in YYYY-MM-DD HH:MM:SS format (24-hour clock)."
    :    SET &Build_InputCheck_String# = "NO"
    :  ENDSWITCH
    :  IF &Build_InputCheck_String# = "YES"
    !    Assemble list of possible values from element data source.
    :    SET &DS_Hnd# = PREP_PROCESS_VAR(&PromptSet_Element_DataSource#)
    :    PROCESS &DS_Hnd#
    :      SET &DS_Value# = GET_PROCESS_LINE(&DS_Hnd#,&Column_To_Read#)
    :      IF &InputCheck# = ""
    :        SET &InputCheck# = "'&DS_Value#'"
    :      ELSE
    :        SET &InputCheck# = "&InputCheck#,'&DS_Value#'"
    :      ENDIF
    :    ENDPROCESS
    :    CLOSE_PROCESS &DS_Hnd#
    :  ENDIF
    !  Because the :READ command accepts only specific variable names as the first arugment,
    !  the names of all of the prompt set variables that might be encountered must be
    !  hard-coded here, each with its own CASE clause in the SWITCH...ENDSWITCH block.
    :  SWITCH &VarName#
    :  CASE "INTEGER1#"
    :    READ &INTEGER1#, &InputCheck# , &Caption#, &Default#, &InputHandling#
    :  CASE "TEXTFIELD1#"
    :    READ &TEXTFIELD1#, &InputCheck# , &Caption#, &Default#, &InputHandling#
    :  CASE "COMBOBOX1#"
    :    READ &COMBOBOX1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "RADIOGROUP1#"
    :    READ &RADIOGROUP1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "CHECKGROUP1#"
    :    READ &CHECKGROUP1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "CHECKLIST1#"
    :    READ &CHECKLIST1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "TIME1#"
    :    READ &TIME1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "DATE1#"
    :    READ &DATE1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  CASE "TIMESTAMP1#"
    :    READ &TIMESTAMP1#, &InputCheck#, &Caption#, &Default#, &InputHandling#
    :  ENDSWITCH
    :  PRINT
    !  If this is the last element in the prompt set, end the READ block.
    :  IF &Counter# = &NumRows#
    :    ENDREAD
    :  ENDIF
    :ENDPROCESS
    :CLOSE_PROCESS &PPP_Hnd#
    :PRINT "--- END UC0.PREP_PROCES_PROMPTSET.JOBI ---"

     

    I also made a more complicated prompt set to test each element type.

     

    The script that uses the JOBI looks like this:

    :SET &Verbose_mode# = "NO"
    :SET &Obscure_text_input# = "NO"
    :SET &PromptSet_Name# = "UC0.PROMPT_SET-TEST2.PRPT"
    :INC UC0.PREP_PROCES_PROMPTSET.JOBI

     

    And the dynamically generated prompt set looks like this:

     

    It’s not perfect. Check box groups and lists cannot be recreated correctly; and time, date, and timestamp fields are recreated as simple text input fields. Still, I think it should be good enough for simple prompt sets. Note that the captions for each field are being read from the Custom field in the prompt set. I simply copied the caption for each element to the custom field to make this possible. (For some reason, it’s not possible to read prompt set element captions using :PREP_PROCESS_PROMPTSET.)

     

    #:prep_process_promptset #promptset #prpt #caautomicworkloadautomation #caautomicautomationengine

    Attachment(s)



  • 6.  Re: Rebuild Prompt - Substitution VARA in ":READ - Command"

    Posted Aug 21, 2018 10:01 AM

    The latest and greatest version of the JOBI can be found here:

    Generate input dialog box dynamically from prompt set object 

     

    This version uses an SEC_SQLI to read additional details about the prompt set, and is thus able to reproduce the input dialog more faithfully.