:PUT_VAR

Script Statement: Stores a value in a static Variable object.

Syntax

:PUT[_VAR]Variable,[Validity Keyword], Value [,Value[,Value[,Value[,Value]]]]

Syntax

Description/Format

Variable

The name of the Variable object to which one or several values should be assigned.
Format: AE name or script variable

Validity Keyword

The line in which the value should be stored.
Format: script literal, script variable or script function

Value

Entries that should be written to the particular value columns. Values of non-specified columns are deleted. Existing values are overwritten.
Format: script literal, script variable or number specified without quotation marks

Should you use this statement with the Variable object XML, only complete (i.e. well-formed) XML is allowed.

Comments

The following general rules apply:

Separate the individual values by using commas, if you want to fill several value columns of a variable. Static variables are limited to 5 value columns.

The parameter Key is optional if the setting "Scope" - "No scope" is selected in the Variable Settings section of the Variable object's Attributes page. In this case, the variable contains only one value. Ensure that the commas are set in the statement even if Key is not used.

You can also specify the individual values without using inverted commas. Commas are used as separators.

Variable objects may have different numbers of values. If you enter more values than the object provides, an error message is displayed.

When using this script statement with the static Variable object XML, the values for XML data type will be beautified automatically. That means, you may use XML in a single script line for example, but in the object the value will be rearranged according to the XML standard.

For example: Values are entered in all the five value columns.

 :PUT_VAR VARA.TEST, "KEY1", "Value1", "Value2", "Value3", "Value4", "Value5" 

To write a value that includes one or several commas in one line, you must enclose this value in single-quote or double-quote characters.
For example: "Value1" is written to the value column 1 and "Value2, Value3, Value4" to column 2.

:PUT_VAR VARA.TEST, "KEY1", "Value1", "Value2, Value3, Value4"

In the following example for the Variable object XML only one value is used, as the Variable object of the type XML only contains one value field:

:PUT_VAR VARA.XML, "KEY1", "<Value1>this is a test</value1>"

One of the following formats must be selected in order to store a value in a variable  of data type "timestamp":

The data types "Time", "Date" and "Number" require the value to be specified in the defined output format (Attributes tab).
Important note for the data type "Number": Redundant decimal places are truncated if an attempt is made to store a number with more decimal places than have been defined in the output format.

This script function writes values to a Variable object even if a user has opened it in order to ensure that there is no interference with processing. A warning displays if a user tries to store the modifications that were made in this Variable object. It contains the information that the variable has been modified in the meantime. The user can now decide whether the modifications should be stored or removed.

For string data types, leading and trailing blanks remain in the content.

The following peculiarity applies if :PUT_VAR is used before a :READ statement: If script generation is canceled manually using the "Cancel" button or due to invalid default values (see "Generate at runtime"), the Variable object still contains the values that were set with :PUT_VAR.

Examples

In the following example the current date and time are determined and saved in a Variable object of the data type "Time stamp". Date and time are transferred to the script statement as script variables.

:SET &DATE# = SYS_DATE("YYYY-MM-DD")
:
SET &TIME# = SYS_TIME("HH:MM:SS")
:
PUT_VAR BOOKING.DATE, , "&DATE# &TIME#"

The variable "ATTRIBUTES", which is used in the following example, contains the scope "Freely selected". Therefore, the Key must be entered.

:SET &PRIO# = GET_ATT("UC4_PRIORITY")
:
PUT_VAR ATTRIBUTES, "CurrentPriority", &PRIO#

 In the following example, a task's name, object type and parent information are stored with the task's RunID in the Variable object "OBJECT_STAT".

:SET &PNAME# = SYS_ACT_PARENT_NAME()
:SET &PNR#SYS_ACT_PARENT_NR()
:SET &PTYPE# = SYS_ACT_PARENT_TYPE()
:SET &NAME#SYS_ACT_ME_NAME()
:SET &NR#SYS _ACT_ME_NR()
:SET &TYPE#SYS_ACT_ME_TYPE()

:PUT_VAR OBJECT_STAT, "&NR#", "object name: &NAME#", "object type: &TYPE#", "parent name: &PNAME#", "parent runid: &PNR#", "parent object type: &PTYPE#"

See also:

Script element Description

:DELETE_VAR

Deletes one or all values of a Variable object.
GET_VAR This returns the value of a Variable object.

RESOLVE_VAR

Resolves any kind of variable (prompt values, system variables, script variables, variable objects) in text.
:SET_SCRIPT_VAR Sets the values of script variables by indirect access.

GET_SCRIPT_VAR

Returns the values of script variables by indirect access.
PREP_PROCESS_VAR and PREP_PROCESS_VAR_XML Prepares the processing of a data sequence (values of a Variable object).

Script Elements - Read or Modify Objects

Variable

Sample Collection:
Database Maintenance with Options

Calling an MBean

About Scripts
Script Elements - Alphabetical Listing

Script Elements - Ordered by Function