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:parameter, Parameters

Other versions: 7.31 | 7.40 | 7.54

Syntax


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

Effect

The statement tt:parameter can be used in an ST program to declare one or more parameters outside of a template. The attribute name is used to define a symbolic name. This name can be used to access the parameter. 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 variables declared with tt:variable.

You can directly access the parameters in the context of the main template. In subtemplates, the parameters of the main template are not known.

Parameters are special variables and can be used as such. Parameters also take effect as formal parameters of an ST program (or a subtemplate):

  • In tt:call (or tt:apply), a current value can be assigned to a parameter with tt:with-parameter.
  • You can use the PARAMETERS addition of the ABAP statement CALL TRANSFORMATION to assign an ABAP data object to a parameter as a current parameter.

You can use ref-type to define the formal parameter 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 kind to specify the kind of formal parameter. Possible values for kind are:

  • "in" input parameter - During the call, an input parameter uses the value of the assigned actual parameter. During the return, the actual parameter does not use the current value of the formal parameter.
  • "out" output parameter - During the call, an output parameter does not use the values of the assigned actual parameter. During the return, the actual parameter uses the current value of the formal parameter.
  • "in/out" input/output parameter - During the call, an input/output parameter uses the value of the assigned actual parameter and, during the return, the actual parameter uses the current value of the formal parameter.

If you do not specify kind, then the formal parameter is by default an input parameter.

The additions s-val and d-val or val can be used to assign a replacement value to any of the input parameters; specify the values as ABAP values. If no current parameter is assigned to an input parameter, it is set to the replacement value. s-val only takes effect during serialization, d-val only takes effect during deserialization, and val takes effect during both serialization and deserialization. You cannot assign replacement values to output parameters and input/output parameters.


Example

This example demonstrates how parameters are passed to a called transformation. The same example is used for subtemplates in the tt:apply statement.

The transformation below has three parameters PARA1, PARA2, and PARA3.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:parameter kind="in" name="PARA1" val="4"/>
  <tt:parameter kind="out" name="PARA2"/>
  <tt:parameter kind="in/out" name="PARA3"/>
  <tt:template>
    <tt:assign to-var="PARA2" var="PARA3"/>
    <tt:assign to-var="PARA3" var="PARA1"/>
    <tt:assign to-var="PARA1" val="555"/>
  </tt:template>
</tt:transform>

It can be called from the transformation below:

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:variable name="VARI1" val="1"/>
  <tt:variable name="VARI2" val="2"/>
  <tt:variable name="VARI3" val="3"/>
  <tt:template>
    <tt:call transformation="...">
      <tt:with-parameter name="PARA1" var="VARI1"/>
      <tt:with-parameter name="PARA2" var="VARI2"/>
      <tt:with-parameter name="PARA3" var="VARI3"/>
    </tt:call>
    <X1>
      <tt:write var="VARI1"/>
    </X1>
    <X2>
      <tt:write var="VARI2"/>
    </X2>
    <X3>
      <tt:write var="VARI3"/>
    </X3>
  </tt:template>
</tt:transform>

The result of the calling transformation is:

<X1>1</X1>
<X2>3</X2>
<X3>1</X3>

The input parameter PARA1 is changed in the called transformation, but the changed value is not passed back to the actual parameter VARI1.

The output parameter PARA2 is set to the value of actual parameter VARI3, which is passed to the called transaction, and this value is returned to the actual parameter VARI2.

The input/output parameter PARA3 is set to the value of actual parameter VARI1, which is passed to the called transaction, and this value is returned to the actual parameter VARI3.