Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Simple Transformations →  ST - Structure of ST Programs →  ST - Data Declarations 

ST - tt:variable, Variables

Other versions: 7.31 | 7.40 | 7.54

Syntax


<tt:variable name="..." [ref-type="..."] 
                        [[s-val="..."][d-val="..."]]|[val="..."] />

Effect

With the tt:variable statement, you can declare one or multiple variables in an ST program outside of a template. You use the name attribute to declare a symbolic name, which can be used to access the variable. This name can have a maximum of 30 characters.

The symbolic name is not case-sensitive and must be unique. The namespace also includes the data roots declared with tt:root and the parameters declared with tt:parameter.

You can directly access the variables in the context of the main template. The variables of the main template are not known in subtemplates.

Variables consist of data from the ST program, which in contrast to the data roots, are not bound to ABAP data objects.

You can use ref-type to define the variable as a reference variable. The value of ref-type determines the static type of the reference variable. All global ABAP classes and interfaces for an object reference variable are possible, as are data types for a data reference variable. The names of classes and interfaces are declared directly and without namespaces. The names of data types must be declared using an XML namespace that determines the context of the data type, as with tt:type. Class reference variables and interface reference variables are intended primarily for creating objects and calling instance methods; data reference variables, however, are used for binding appropriately typed interface parameters when ABAP methods are called.

Use the additions s-val and d-val or val to assign a start value to any of the variables; specify the values as ABAP values. s-val only works for serialization, d-val only works for deserialization, and val works for serialization and deserialization.

Within a template, you use the tt:assign statement to assign a value to a variable. You access the variables using the var attribute of the various ST statements.