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:call-method, Calling Instance Methods
Syntax
<tt:call-method var="oref" [s-|d-]name="meth"
[writer = "writer_para"]
[reader = "reader_para"] >
[<tt:with-parameter [s-|d-]name="para1"
[ref="node1"|val="val1"|var="var1"] />
<tt:with-parameter [s-|d-]name="para2"
[ref="node2"|val="val2"|var="var2"] />
...]
</tt:call-method>
Effect
Using this variant of the tt:call-method statement, you can call an instance method of a global ABAP Objects class in an ST program as follows: You can use var to declare a variable or a parameter of the ST program. The ref-type addition must have been used to create the variable or parameter as a class reference variable or interface reference variable. When called, the variable or parameter must point to the object of a class. The object can have been generated either in the ST program using tt:create-object, or it is referred to a corresponding ABAP reference variable.
You can use meth to declare a visible method that exists in the static type of the reference variable, that is, in the class or interface. The declaration of the method is not case-sensitive.
Method execution, parameter passing, and optional attributes are subject to the same conditions as static method calls.
Example
The following transformation calls an instance method convert in an object that is referenced by the parameter OPAR. This is transferred to the input parameter input of the method, and its return code result is assigned to a variable with the same name. The variable result is then serialized using tt:write. Note that no data root can be assigned to the return code of the method during serialization.
The following is an example of a calling ABAP program:
A reference to an object of the required class is transferred with the addition PARAMETERS.
The method convert of the class cls is defined as follows:
The result of the transformation is as follows: