Sample Collection Guide > Dynamic Input Dialog for Job Activation

Dynamic Input Dialog for Job Activation

Objective: The creation of an input mask in order to select one or several agents on which a job should run. The available agents are dynamically retrieved from the AE databaseA database is an organized collection of data including relevant data structures. at runtime. In the input dialog, you must also specify a Queue object and an OS command for the jobs. As a result, you can easily define the OS command that should be processed on particular computers.

Objects used: PromptSet, Script, Job (Windows), Variable (SQL internal)

Script elements used: :SET, :PSET, :WHILE :ENDWHILE, :IF :ELSE :ENDIF, LENGTH, SYS_HOST_ALIVE, ACTIVATE_UC_OBJECT, :PRINT, :DATA, :PUT_ATT

Requirements: Creating and using internal SQL variables (the privilege and setting SQLVAR_INTERNAL = Y in the variable UC_SYSTEM_SETTINGS is required).

This example describes the use of PromptSet objects, dynamic Variable objects, predefined variables and script arrays.


Example

You can enter user-defined values by using a PromptSet object which is called via a Script object. The available Queue objects and Windows agents are directly retrieved from the AE database by using SQL-internal Variable objects. Submitting the PromptSet dialog has the effect that a job starts on each selected agent.

Defining the Input Mask

PromptSet objects are user-defined input masks that can be called by using executable objects. You can use PromptSet object elements in order to enter or select values that are retrieved from a Variable object (= reference variable).

First, create the reference Variable objects: Create the following two SQLI-type Variable objects: VARA.SQLI.AGENT and VARA.SQLI.QUEUE.

The advantage of SQL-internal Variable objects is that their values are dynamically retrieved from the AE database at runtime. This means that the PromptSet element always shows the current values. For example, if a new agent is added, it is automatically displayed the next time the input mask is called. You can also use static variables but their contents must be maintained manually.

One of the two variables reads all the current client's Windows agents and the other one all Queue objects from the AE database. Insert the following SQL statements in the Variable objects if you use an MS SQL Server database:

If you use a different database (Oracle or DB2), adjust these SQL statements accordingly. Use the "Preview" in order to verify that the SQL statements are correct. They are correct if the values are displayed without an error.

&$CLIENT# is a predefined variable that is replaced by the current AE client's number at runtime. At least VAR_SECURITY_LEVEL = 1 (or 2, or 3) must be set in the variable UC_SYSTEM_SETTINGS in order to resolve this variable.

 

Create the new PromptSet object PRPT.AGENT.

Open this object and switch to its Designer tab. You can now use the drag & drop function in order to drag the required PromptSet elements from the right area to the center.

The following PromptSet elements are required for this example:

Elements Description Properties
Text field For the job name (a fixed name in this example)
  • Data reference: UC_DATATYPE_STRING
  • Value required
  • Variable name: job#
  • Label: Job
  • Locked
  • Default value: JOBS.WIN.PROMPT
Check list For the selection of one or several Windows agents.
  • Data reference: VARA.SQLI.AGENT
  • Value required
  • Multiple selection, array
  • Variable name: agent#
  • Label: Agent
Combo box For the selection of a Queue object.
  • Data reference: VARA.SQLI.QUEUE
  • Variable name: queue#
  • Label: Queue
  • Default value: &$QUEUE# (Script object's queue)
Text field Input of an OS command.
  • Data reference: UC_DATATYPE_STRING (default)
  • Value required
  • Variable name: jcl#
  • Label: JCL
  • Default value: dir C:\

 

Script Object

The Script object is used to call the PromptSet object, read its values and activate the jobs.

Create the Script object SCRI.START.JOBS.

Open this object and switch to the Variables & Prompts tab. In "PromptSets", select the created PromptSet object PRPT.AGENT. You can now overwrite the PromptSet elements' default values if necessary.

Switch to the Process tab and insert the following lines:

:SET &LEN# = LENGTH(&AGENT[])
:WHILE &LEN# > 0
: PSET &HOST# = &AGENT[&LEN#]
: IF SYS_HOST_ALIVE(&HOST#) = "Y"

: SET &RET# = ACTIVATE_UC_OBJECT(&JOB#,,,,,PASS_VALUES,&queue#,"&JOB#_&HOST#")
: P "Start Job &JOB# on agent &HOST# with RunID &RET#"
: ELSE
: P "Agent &HOST# is not active."
: ENDIF
: SET &LEN# = &LEN# - 1

:ENDWHILE

This script is used to retrieve the number of agents that have been selected in the PromptSet object. Subsequently, the agent names are read from the script array. If the agent is active, the Windows job starts.

The job executions start with an alias to enable them to be distinguished in the statistics. This alias is composed of the job and agent names. For example: JOBS.WIN.PROMPT_WIN01.

 

Windows Job

Create the Windows Job object JOBS.WIN.PROMPT.

Open the job and enter a Login object that can be used with all Windows agents in the Attributes tab. Switch to the Pre-Process tab and insert the following line:

: PUT_ATT HOST = &HOST#

The effect is that the agent that was passed on by the Script object using an object variable is dynamically set at runtime.

The following lines are required in the Process tab in order to execute the user-defined Windows command:

:DATA &jcl#
:DATA "@set retcode=%errorlevel%"
:DATA "@if NOT %ERRORLEVEL% == 0 goto :retcode"

 

Result

Start the Script object in order to call the input dialog. Select the required agent and a Queue object. In the field "JCL", enter the Windows command that should be processed on the computers of the selected agents.

In this example, the job JOBS.WIN.PROMPT starts in the queue CLIENT_QUEUE on the agents WIN01, WIN02 and WIN03. The file list C:\ is queried on the computers of these agents.

As a result, you can quickly and easily execute user-defined commands on several computers.

s