SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → Simple Transformations → ST - Access to ABAP Objects from ST →ST - tt:create-object, Creating Objects
Syntax
<tt:create-object var="oref" [class="class"]>
[<tt:with-parameter name="para1"
[ref="node1"|val="val1"|var="var1"] />
<tt:with-parameter name="para2"
[ref="node2"|val="val2"|var="var2"] />
...]
</tt:call-method>
Effect
Using the tt:create-object statement, you can call an instance of a global ABAP Objects class in an ST program. You can use var to declare a variable or a parameter of the ST program. The variable or parameter must have been created as a class reference variable or an interface reference variable with the ref-type addition.
The object is created in the internal session of the ABAP program that called the ST program. If the class attribute is not declared, var must be a class reference variable and an instance of the relevant class is created. If the class attribute is declared, an instance of the specified class is created. You can specify a global class from the ABAP class library for class, either more special or the same as the static type of the reference variable var:
The interface parameters para1, para2, ... of the instance constructor of the class of the object can or must be bound to actual parameters, using the ST command tt:with-parameter. The same rules apply here as to regular method calls. Constructor exceptions are also handled in the same way as exceptions for regular method calls.
After the object has been created, the reference variable var points to the object and can be used to call instance methods.
Example
The following Simple Transformation uses the variable ovar to create an object of the class cls. When doing this, it passes the data root PARA to the parameter repl of its instance constructor. The method convert is then called, whose input/output parameter is assigned the variable result. Note that a data root cannot be assigned to an input/output parameter - neither during serialization nor deserialization.
The following is an example of a calling ABAP program:
The constructor and the method convert of the class cls are defined as follows:
The result of the transformation is as follows: