SAP ST TT CALL-METHOD INSTANCE



Get Example source ABAP code based on a different SAP table
  



ABAP_ST - tt:call-method, Calling Instance Methods

ABAP_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>

What does it do?
Using this variant of the statement tt:call-method, it is possible to call an instance method of a global ABAP Objects class in an ST program as follows: var can be used to specify a variable or a parameter of the ST program. The addition ref-type 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. Either the object can have been created in the ST program using tt:create-object, or it is referred to a corresponding ABAP reference variable.
meth can be used to specify a visible method that exists in the static type of the reference variable, that is in the class or interface . The specification of the method is not case-sensitive.
Method execution, parameter passing, and optional attributes are subject to the same conditions as static method calls.

ABAP_EXAMPLE_VX5
The transformation DEMO_ST_WITH_METHOD_CALL_INST calls an instance method CONVERT in an object that is referenced by the parameter OPAR . This is passed to the input parameter input of the method and its return value RESULT is assigned to an identically named variable. The variable result is then serialized using tt:write. Note that no data root can be assigned to the return value of the method in serializations.
TRNS DEMO_ST_WITH_METHOD_CALL_INST
The transformation is called in class CL_DEMO_CALL_METH_FROM_ST. A reference to an object of class CL_DEMO_CALL_FROM_ST_INST is passed using the addition PARAMETERS. The instance method CONVERT of that class is defined as follows:
METH CL_DEMO_CALL_FROM_ST_INST=>CONVERT
The result of the transformation is as follows: < Result>1-2-3 < /Result>
ABAP_EXAMPLE_END