Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Simple Transformations →  ST - Access to ABAP Objects from ST 

ST - tt:call-method, call static methods

Other versions: 7.31 | 7.40 | 7.54


<tt:call-method class="class" [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"] />


Using this variant of the tt:call-method statement, you can call a static method of a global ABAP Objects class in an ST program as follows: You can use class to specify a class from the class library and you can use meth to specify a visible method of this class. This is not case-sensitive. The method is called for both serializations and deserializations when name is declared; it is called for serializations only when s-name is declared and for deserializations only when d-name is declared.

The interface parameters para1, para2, # of the called method can or must be bound to actual parameters, using the ST command tt:with-parameter. The attribute name specifies the name of a formal parameter. An actual parameter is bound to this attribute only in serializations (if s-name is specified) and only in deserializations (if d-name is specified). In certain cases, this allows you to use a single method for both directions. As actual parameters, you can use ref to specify data roots, var to specify variables or parameters, and val to specify values. Depending on the kind of formal parameter, the values of the specified actual parameters are either passed in the call or used when the called method ends.

When you use actual parameters, note that you have only read-only access to data roots in serializations, which is why they can only be passed to input parameters of the method. In the reverse case (deserializations), you have only write access to data roots, which is why they can be used only by output parameters or return codes.

The type of an actual parameter must match the typing of the interface parameter. The type of a data root, which can itself be typed in the tt:root statement, is determined by the type of the bound ABAP data object. Parameters and variables do not have a static type, unless the ref-type addition of the statements tt:parameter or tt:variable defines them as reference variables. Data reference variables defined in this way can be bound to interface parameters of the same type.

When a method is called, control passes from the ST processor to the ABAP processor of the ABAP runtime environment. There are no restrictions on which statements can be executed in the method. If ENDMETHOD or RETURN is used to exit a method correctly, control passes to the ST processor again and the ST program resumes after tt:call-method. Otherwise, the control does not pass back to the ST program:

  • If a statement such as LEAVE PROGRAM, SUBMIT without the addition AND RETURN, or LEAVE TO TRANSACTION is used to exit the method, the program responds as if the method were called from an ABAP program; that is, the current internal mode is deleted, together with the ST program.
  • If the method is terminated by a class-based exception, and the exception is propagated from the method, the statement CALL TRANSFORMATION is terminated with the treatable exception CX_ST_CALL_METHOD_ERROR. The EXCEPTION_NAME attribute of the exception object is then given the name of the original exception.
  • Non-class-based exceptions cannot be handled. A method terminated using a non-class-based exception always causes a runtime error.

If ABAP data objects are modified in the called method, and these data objects are bound to data roots of the calling ST program, these modifications take effect immediately in the ST program. The following restriction applies: If a method is called within a tt:loop loop, serialization within the method (and within further nested tt:loop loops) only permits read-only access to the current internal table or its components. Deserialization within the method does not allow any access. Otherwise, a runtime error occurs.

Using the optional attributes writer and reader, you can specify the input parameterswriter_para or reader_para of the called method. These parameters must have the references types IF_SXML_WRITER or IF_SXML_READER. If s-name is specified, you can only specify writer. If d-name is specified, you can only specify reader. If name is specified, you can specify both attributes. writer is used for serialization and reader is used for deserialization. Using these attributes, you can pass a reference to the internal writer/reader object (created with CALL TRANSFORMATION when the transformation is called) to the called method. In the method, the relevant interface can be used to access the object.


If variables or parameters are bound to the interface parameters of called methods, note that these variables or parameters can be serialized or deserialized only if they contain elementary values.


The following transformation is available as DEMO_ST_WITH_METHOD_CALL in AS ABAP. In a serialization in a tt:loop loop, it uses the data root SCARR_TAB to call the static method GET_FLIGHTS of the global class CL_DEMO_CALL_FROM_ST. This passes the component carrid of the internal table scarr_tab to the input parameter of the method.

  <tt:root name="SCARR_TAB"/>
  <tt:root name="SPFLI_TAB"/>
      <tt:loop ref=".SCARR_TAB">
          <tt:attribute name="Carrier" value-ref="CARRNAME"/>
          <tt:call-method class="CL_DEMO_CALL_FROM_ST"
            <tt:with-parameter name="CARRID" ref="carrid"/>
          <tt:loop ref=".SPFLI_TAB">
              <tt:attribute name="ID" value-ref="CONNID"/>
                <tt:value ref="CITYFROM"/>
                <tt:value ref="CITYTO"/>

The Simple Transformation can be called in a different method MAIN of the same class DEMO_ST_WITH_METHOD_CALL as follows:

METHOD main.
  DATA:  scarr_tab TYPE SORTED TABLE OF scarr
                    WITH UNIQUE KEY carrid,
         xml_string TYPE string,
         exc        TYPE REF TO cx_st_call_method_error.
         FROM scarr
         INTO TABLE scarr_tab.
  IF sy-subrc <> 0.
      CALL TRANSFORMATION demo_st_with_method_call
        SOURCE scarr_tab = scarr_tab
               spfli_tab = spfli_tab
        RESULT XML xml_string.
    CATCH cx_st_call_method_error INTO exc.
  cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).

The internal tables scarr_tab and spfli_tab are both static attributes of the class. scarr_tab is filled and passed to the transformation data root with the same name; spfli_tab, however, remains empty and is filled in a different way (in the method GET_SPFLI called from the Simple Transformation) in each loop, in accordance with the parameter carrid.

The method MAIN is bound to the transaction code DEMO_ST_METHOD_CALL and produces the following result:

  <Flights Carrier="American Airlines">
    <Connection ID="0017">
      <From>NEW YORK</From>
      <To>SAN FRANCISCO</To>
    <Connection ID="0064">
      <From>SAN FRANCISCO</From>
      <To>NEW YORK</To>
    <Connection ID="0555">
  <Flights Carrier="Air Berlin">

The program above uses the binding of the attribute spfli_tab to the Simple Transformation, and write access to this attribute in the called method, to enable write access to data nodes during serialization within the ST program.