Skip to Content

How to Scan ST & XSLT Programs for Specific Commands

In this weblog I show you a program that scans XSLT programs and Simple Transformations for certain commands. I present you a simple use case: In NW 7.02 Simple Transformations can call ABAP classes by the tt:call-method command. But how does it work? With this program you can scan existing transformations for examples. This is the input:


All XSLT and ST programs are scanned for an element tt:call-method – this is an element call-method in an XML namespace .

The output is as follows:


In fact there are ST programs that contain the command like DEMO_ST_WITH_METHOD_CALL. There are also programs that have syntax errors like SEC_WSSP_POLICY2 which contain severe errors. IMHO SAP should use the program to ensure the quality of transformation in their software.

How does the program work? At first the transformations are selected and loaded using the class cl_o2_api_xsltdesc. Then the XSLT program zscan_transformation is used to scan the program – the result is a boolean flag. Then the result is given out resp. the message that an error occurs:

REPORT  zscan_transformation.

DATA lr_xslt   TYPE REF TO            cl_o2_api_xsltdesc.
DATA ls_trafo  TYPE                   o2xslttext.
DATA lt_trafo  TYPE STANDARD TABLE OF o2xslttext.
DATA lv_source TYPE                   string.
DATA lv_found  TYPE                   abap_bool.

SELECT-OPTIONS s_trafo FOR ls_trafo-xsltdesc.


  SELECT DISTINCT xsltdesc FROM o2xslttext
    INTO TABLE lt_trafo WHERE xsltdesc IN s_trafo.

  LOOP AT lt_trafo INTO ls_trafo.

    CALL METHOD cl_o2_api_xsltdesc=>load
        p_xslt_desc        = ls_trafo-xsltdesc
        p_obj              = lr_xslt
        error_occured      = 1
        not_existing       = 2
        permission_failure = 3
        version_not_found  = 4
        OTHERS             = 5.
    IF sy-subrc = 0.
      lv_source = lr_xslt->get_source_string( ).
          CALL TRANSFORMATION zscan_transformation
            PARAMETERS name      = p_name
                       namespace = p_namesp
            SOURCE XML lv_source
            RESULT result = lv_found.

          IF lv_found = abap_true.
            WRITE :/ 'Found in', ls_trafo-xsltdesc.
        CATCH cx_xslt_runtime_error.
          WRITE :/ 'Error in ', ls_trafo-xsltdesc.
      WRITE :/ 'Could not load: ', ls_trafo-xsltdesc.


How does the transformation ZSCAN_TRANSFORMATION work? It is an XSLT program that gets an XML document (in fact the code of an XSLT or ST program) as input together with two parameters: a name of an XML element and a namespace (in fact an URI).

The result is a boolean flag given back in asXML format  – the typical way to bridge the gap between XML and ABAP. The result is X if and only if the number of elements of given name and namespace is greater than zero, i.e. there is at least one element. This is evaluated in an XPath expression in the following transformation:

<xsl:transform xmlns:xsl= 
  xmlns:asx="" version="1.0">
  <xsl:param name="NAME"/>
  <xsl:param name="NAMESPACE"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
test="count(//node()[namespace-uri()=$NAMESPACE and local-name()=$NAME]) > 0">


Why is this useful? You can find examples for ST commands (ST is a proprietary language) and SAP proprietary XSLT commands. A list of those commands (and of course an explanation together with details) can be found in my SAP Press book about XML in ABAP.

As an easy exercise I suggest you to write a program that scans for XPath functions  which are within certain attributes of an XSLT program. You can also write programs that scan comments or other parts of the transformation which can be useful maintenance of transformations.

You must be Logged on to comment or reply to a post.
  • Hi Tobias,

    Good idea to write such a program. I think that is very use full.

    I also read your book about ABAP and XML. It is really a treasure chest regarding its subject. It’s a pity, that there is no English translation…


    • Hi Peter,

      I’m glad that you liked this book and my blog.

      What do you think of the XML infrastructure of AS ABAP? What is missing? What could be improved? Or do you think it is OK like it is? What about tooling and supported standards?


  • Hi all,

    In complement to the powerful Tobias program, if you want to simply search words or regular expressions, you may launch RS_ABAP_SOURCE_SCAN program by selecting program type “X” (for ST/XSLT programs). Be careful, some of these programs may not have been immediately generated after import in a system, so you’ll have to call the program RS_RETRIEVE_XSLT (it’s more about REPAIR than RETRIEVE) mentioned in note

    1390832 – Problems with “disappeared” STs/XSLTs