Variable In TDL

In TDL, a Variable is one of the important definitions, since it helps to control the behavior of Reports and their contents. Variables assume different values during execution and these values affect the behavior of the Reports.
A Variable definition is similar to any other definition.
[Variable: ]
Attribute : Value
A Variable should be given a meaningful name which determines its purpose.

Attributes of a Variable

Type : – This attribute determines the Type of the value that will be held by the variable. The Types of
values that a variable can handle are String, Logical, Date and Number. In the absence of this
attribute, a variable assumes to be of the Type String, by default.
[Variable: ]
Type :

Default : – This attribute is used to assign a default value to a variable, based on the ‘Type’ defined.
[Variable: ]
Default :
Value of the variable should adhere to the data type specified with ‘Type’ Attribute.
[Variable : DSP HasColumnTotal]
Type : Logical
Default : Yes
The Default Initial Value for the logical Variable DSP HasColumnTotal is set to YES. This variable
will begin with an initial value YES in the Reports, unless overridden by the System Formula. We
will learn about the System Formula in the coming sections.

Persistent : –This attribute decides the retention periodicity of the attribute. If the attribute ‘Persistent’ is set toYES, then the latest value of the variable will be retained across the sessions, provided the variable is not a local variable. We will learn about the concept of local and global variables shortly.


[Variable: ]

Volatile : – In cases where the ‘Volatile’ attribute in the Variable definition is set to YES, the variable is capable of retaining multiple values, i.e., its original value with its subsequent values, are stored as a stack. The default value of this attribute is YES. In cases where a new report R2 is initiated, using a volatile variable V, from the current report R1, the current value of the volatile variable will be saved as in a stack, and the variable can assume a new value in the new report R2. Once the previous report R1 is returned back from the report R2, the previous value of the variable will be restored. A classic example of this is a drill-down Trial Balance.


[Variable: ]

Repeat : –This attribute is mainly used to achieve the Auto Column behaviour in various Reports. Each Column is created with a subsequent Object in a Collection automatically, till all the columns required for Auto Columns exhaust. The ‘Repeat’ attribute has its value as a variable which has the collection of Objects, for which the columns need to be generated. Every time the Repeat is executed, the column for the subsequent Object is added.


[Variable: ]
Repeat :

The Scope of a Variable : – The scope of a Variable can be broadly classified as follows:

  • Local
  • Global
  • Field acting as a variable

Local : – A Variable is termed as a local variable when it is associated to a Report. This means that the scope of the variable covers only the current report and its components. It is not mandatory for local variables to have an initial value.


[Report : ]

Global : –

A variable is termed as Global variable when it is defined under System Variable section. It means
that the scope of the variable covers all reports. An initial value is mandatory for global variables.

Note : – A Global Variable can also be made local to a Report by associating it to a Report, as
discussed in Local Variables above.

Field Acting as a Variable : – The Variable attribute in a ‘Field’ Definition is used to make the Field behave as a Variable. This means that as soon as some value is entered/altered in a Field, the variable assumes the same value with immediate effect. The Variable need not be defined previously, since it inherits its data type from the Field itself.

Note :- The Variables used in a Field Acting as a Variable are local variables, and are local to the Report.

Variable In TDL Read More »