Questions concerning ST Simple Transformations

I got some questions concerning Simple Transformations:
1.) When editing a simple transformation, how to insert comments? In pure ABAP, a comment line must have as asterisk in the first column...
2.) I use <tt:loop>...</tt:loop> and want to use the index of the currently processed entry, like SY-TABIX when implementing a "LOOP AT itab" in ABAP. Is there a way?
Thanks for your answer, points will be rewared...
-MIKE

Hi Jack, please find some sample coding below that will solve your issue:
<tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
  <INCO1 tt:value-ref="E1EDL20.INCO1"/>
</tt:cond>
With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.
Regards. Please give points when usefull !

Similar Messages

  • Simple Transformation to deserialize an XML file into ABAP data structures?

    I'm attempting to write my first simple transformation to deserialize
    an XML file into ABAP data structures and I have a few questions.
    My simple transformation contains code like the following
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
                  xmlns:pp="http://www.sap.com/abapxml/types/defined" >
    <tt:type name="REPORT" line-type="?">
      <tt:node name="COMPANY_ID" type="C" length="10" />
      <tt:node name="JOB_ID" type="C" length="20" />
      <tt:node name="TYPE_CSV" type="C" length="1" />
      <tt:node name="TYPE_XLS" type="C" length="1" />
      <tt:node name="TYPE_PDF" type="C" length="1" />
      <tt:node name="IS_NEW" type="C" length="1" />
    </tt:type>
    <tt:root name="ROOT2" type="pp:REPORT" />
        <QueryResponse>
        <tt:loop ref="ROOT2" name="line">
          <QueryResponseRow>
            <CompanyID>
              <tt:value ref="$line.COMPANY_ID" />
            </CompanyID>
            <JobID>
              <tt:value ref="$line.JOB_ID" />
            </JobID>
            <ExportTypes>
              <tt:loop>
                <ExportType>
                   I don't know what to do here (see item 3, below)
                </ExportType>
              </tt:loop>
            </ExportTypes>
            <IsNew>
              <tt:value ref="$line.IS_NEW"
              map="val(' ') = xml('false'), val('X') = xml('true')" />
            </IsNew>
          </QueryResponseRow>
          </tt:loop>
        </QueryResponse>
        </tt:loop>
    1. In a DTD, an element can be designated as occurring zero or one
    time, zero or more times, or one or more times. How do I write the
    simple transformation to accommodate these possibilities?
    2. In trying to accommodate the "zero or more times" case, I am trying
    to use the <tt:loop> instruction. It occurs several layers deep in the
    XML hierarchy, but at the top level of the ABAP table. The internal
    table has a structure defined in the ABAP program, not in the data
    dictionary. In the simple transformation, I used <tt:type> and
    <tt:node> to define the structure of the internal table and then
    tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
    can occur zero or more times. But every variation I try seems to get
    different errors. Can anyone supply a working example of this?
    3. Among the fields in the internal table, I've defined three
    one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
    XML file, I expect zero to three elements of the form
    <ExportType exporttype='csv' />
    <ExportType exporttype='xls' />
    <ExportType exporttype='pdf' />
    I want to set field TYPE_CSV = 'X' if I find an ExportType element
    with its exporttype attribute set to 'csv'. I want to set field
    TYPE_XLS = 'X' if I find an ExportType element with its exporttype
    attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
    an ExportType element with its exporttype attribute set to 'pdf'. How
    can I do that?
    4. For an element that has a value like
    <ErrorCode>123</ErrorCode>
    in the simple transformation, the sequence
    <ErrorCode>  <tt:value ref="ROOT1.CODE" />  </ErrorCode>
    seems to work just fine.
    I have other situations where the XML reads
    <IsNew value='true' />
    I wanted to write
    <IsNew>
            <tt:value ref="$line.IS_NEW"
            map="val(' ') = xml('false'), val('X') = xml('true')" />
           </IsNew>
    but I'm afraid that the <tt:value> fails to deal with the fact that in
    the XML file the value is being passed as the value of an attribute
    (named "value"), rather than the value of the element itself. How do
    you handle this?

    Try this code below:
    data  l_xml_table2  type table of xml_line with header line.
    W_filename - This is a Path.
      if w_filename(02) = '
        open dataset w_filename for output in binary mode.
        if sy-subrc = 0.
          l_xml_table2[] = l_xml_table[].
          loop at l_xml_table2.
            transfer l_xml_table2 to w_filename.
          endloop.
        endif.
        close dataset w_filename.
      else.
        call method cl_gui_frontend_services=>gui_download
          exporting
            bin_filesize = l_xml_size
            filename     = w_filename
            filetype     = 'BIN'
          changing
            data_tab     = l_xml_table
          exceptions
            others       = 24.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.

  • A question about simple transformation

    Hello Experts,
    I wrote a simple transformation according to certain XML structure. But when I ran the transformation with an XML file, an exception will pop up as following
    "Attribute 'requestListId' expected"
    So I executed my program once again in debug mode and go inot the transformation. The exception comes from the following line
    <tt:attribute name="requestListId" value-ref="REQUEST_LIST_ID"/>
    I can open the XML file with IE. I checked the XML carefully and can't find anything wrong.
    I really don't why the exception poped up. 
    Can any expert provide support and help in Transformation programming and Transfromation debug?
    Thanks a lot.
    Best Regards, Johnney.

    Have other solution. So close it.

  • Using Simple Transformations with Objects tt:copy .. results in Exception

    Question:
    How can I serialize an ABAP-Object-Instanz with my own simple transformation?
    In the sap-documentation I found the following solution for the serialisation of any data-objects.
    "z_steffens_simple_transf":
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"/>
      <tt:template>
        <root>
          <tt:copy ref="ROOT"/>
        </root>
      </tt:template>
    </tt:transform>
    Following the example I wrote this report:
    report  zspahr_test_simple_transf.
    class serializable definition.
      public section.
        interfaces if_serializable_object.
        data attr type string value 'Attribute'.
    endclass.         
    method main_serializable.
        data: oref type ref to serializable,
              xmlstr type xstring.
        create object oref.
        call transformation id
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
        call transformation z_steffens_simple_object
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
      endmethod.                    "main_
    start-of-selection.
      demo=>main_serializable( ).
    Executing this report leads to an exception "CX_SY_REF_NOT_SUPPORTED".
    The "standard" transformation "ID" ist working an translates my object-instance into an asXML representation:
      <?xml version="1.0" encoding="utf-8" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
      <ROOT href="#o3" />
      </asx:values>
    - <asx:heap xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abap="http://www.sap.com/abapxml/types/built-in" xmlns:cls="http://www.sap.com/abapxml/classes/global" xmlns:dic="http://www.sap.com/abapxml/types/dictionary">
    - <prg:SERIALIZABLE xmlns:prg="http://www.sap.com/abapxml/classes/program/ZSPAHR_TEST_SIMPLE_TRANSF" id="o3">
    - <local.SERIALIZABLE>
      <ATTR>Attribute</ATTR>
      </local.SERIALIZABLE>
      </prg:SERIALIZABLE>
      </asx:heap>
      </asx:abap>
    How can I do this with my own Simple Transformation "ZSPAHR_TEST_SIMPLE_TRANSF" ?
    I want to serialize my object using my own xml-structure, not the asXML-structure !
    Regards
    Steffen

    Hi,
    try like this,i think it may help you.
    ABAP:
    CALL TRANSFORMATION ztrans_test
          SOURCE
               root = partab
         RESULT XML lv_xstring.
    Trnsformation:
    <tt:root name="ROOT" type="?"/>
    <tt:template>
    <VALUES>
    <VALUE_SOURCE>
            <tt:value ref=".ROOT"/>
    </VALUE_SOURCE>
    <VALUE_PARAM>
    <tt:value ref="NAME"/>
    <tt:value ref="VALUE"/>
    </VALUE_PARAM>
    </VALUES>
    Thanks,
    Rajesh.

  • ABAP to XML File (Simple Transformation)

    Hi guys,
    this is my first question here and if I do something wrong please tell me about it.
    I created my own simple transformation which I use in my program:
    CALL TRANSFORMATION ZST_MAGAZYN_BB
         SOURCE lt_magazyn_rh = lt_magazyn_rh[]
                lt_mag_hdr = lt_mag_hdr[]
                lt_mag_hdr2 = lt_mag_hdr2[]
         RESULT XML xml_string.
    Then I tried to use GUI_DOWNLOAD on "xml_string" but there is no content in output xml file (but file's size is not 0kb):
    DATA:  xml_table TYPE STANDARD TABLE OF string.
    APPEND xml_string TO xml_table.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
         filename = 'C:\rh.xml'
       TABLES
         data_tab = xml_table.
    I would really appreciate your help.

    Try to change the path where you're saving the file.
    I had the same problem once, it was authorization. I couldn't save in C:\ root.
    Change filename = 'C:\rh.xml'   to    filename = 'C:\TEMP\rh.xml'.
    Or try any other path, but C:\

  • Question concerning Servicing

    Hey all.
    I have a question concerning the servicing of my Macbook.
    My laptop (less than a year old and still under warrenty) has several dead pixels on the display and the case has developed a chip on the palm rest when the display lid (prongs) meets the palm rest (I believe that this is a popular problem). I did initiate a self repair on the chipped palm rest with super glue to fix it temporarily.
    The question is if i take my laptop to the Genius bar, will I be able to get both the screen repaired and the palm rest repaired. And if so how long do you think it will take to replace both and any indication about costs.

    jfdm wrote:
    Hey all.
    I have a question concerning the servicing of my Macbook.
    My laptop (less than a year old and still under warrenty) has several dead pixels on the display and the case has developed a chip on the palm rest when the display lid (prongs) meets the palm rest (I believe that this is a popular problem). I did initiate a self repair on the chipped palm rest with super glue to fix it temporarily.
    The question is if i take my laptop to the Genius bar, will I be able to get both the screen repaired and the palm rest repaired. And if so how long do you think it will take to replace both and any indication about costs.
    I would think you would have no problem with just a simple super-gluing of the palm rest, provided you didn't get it all over the rest of the case. Dead pixels may be another issue. Industry standards say that a certain amount of dead pixels are acceptable. Yield would go way down if all LCD panels were required to be perfect and stay perfect. Your best course of action is to make an appointment and ask. Good luck.

  • Dreamweaver cs6 suite development questions/concerns

    Hello,
    I am new a new creative cloud subscriber. I have past experience with programming a java environments and SQL. I am new to HTML5/CSS3 and have read a book on the subject to understand the design concepts in effort to find a good environment to develop mobile applications. I like what I see using fireworks to create HTML5/CSS3 to create code for more complex objects/elements.
    Additionally, watched all the videos and am ready to roll up my sleeves and get started. As I have watched the videos and goggled allot of forums regarding DM CS6 and web applications I have a few questions and concerns. I will preface this with the understanding that this involves new features/ technologies and will suffer some growing pains.
    Questions/ Concerns:
    1) Fluid Grid Layout tool:
    Can I create a mobile application with this tool that will work on both tablets and smart phones (not desktops) compiling  a single optimized site using the phone gap tool; or do I have to create 2 separate site and compile?
    2) Phone Gap
    I have read that there are allot of issues with compiling applications. Even watching the adobe road show video, they could not get it to work (yikes).I have also read that I phone product code need to be compiled using xcode(tools); needed to have an apple subscription (which I have access to) What are the known issues compiling mobile applications for the different device platforms?
    3) Sever-Side Mobile Applications
    a) As I understand it, this cannot be accomplished with this environment without a web service that     communicates to the server-side scripting/ Database server.
    b) Reading about local storage, what are the limitations and how do they effect mobile applications if there is more complex scripting and large record sets?
    C) Are there ways to create user/ security roles (I would imagine the integrity issues with security would be staggering)?
    4) Responsiveness
    I have played around DM, I have noticed it crashing and being very sluggish. I know its not memory or processing issues as I have read several posts on the topic.
    It seems that adobe is making it easier to design and develop within one product/suite. These tools seem very powerful. The direction makes sense as I like elements of both development and design. I am concerned that I will hit walls and want to avoid banging my head. I am still new to this environment and the mistakes may be mine. With that being said, do you think Adobe will get these issues resolved out and have a great environment and development model.
    Thanks in advance for the light anyone can shed on these subjects as I am eager to get started (but a bit worried).
    Erich

    Hi
    To add to Davids reply -
    Item 3:
    Are you talking about apps. or web pages on mobile devices, (they are not the same thing)?
    If web pages then the server/database side is no different to a normal web page which does require a server supporting these. As for local storage, (works whilst off-line) this is normally done via javascript and a local database, but I would not use this feature for anything too complicated as the database is stored on the users computer/device, and only 'communicates' with your server/database when the user is once again on-line and connected to your web page.
    As for item 3.c. - Doing this for off-line use is a complete waste of time, as the user has access to any encryption code and the database entry's, which they can then use when on-line again. A simpler solution would be to require just the users credentials and store this locally, (still not ideal, but at least all the users DB is not downloaded).
    Regarding item 4. Some users have reported problems, but for me personally 99.9% of them I have not experienced with the release version of CS6, and performance issues for me all vanished when I upgraded my PC to an i7 processor with 16Gb memory, an extreme solution for many I admit, but your computers speed and memory will have a dramatic effect on the user experience.
    PZ

  • How to escape special characters in Simple Transformation

    Hi Experts,
    I have got a problem to get a well formed xml document from the below simple transformation. The content of maktx contains
    special characters like & <, which are not allowed in a well formed XML-Document. But the result of the Simple Transformation
    contains this charcters even after the transformation as you can the in the result below. Has anyone a hint how to escape the
    characters included in the maktx.
    The transformation for maktx, should be something like
    Before: Material & < TEST
    After: Material &amp &lt TEST
    Report wihich calls the simple transformation
    types:
    BEGIN OF t_mat,
       matnr type matnr,
       maktx type maktx,
    end of t_mat.
    Data:
      mat type t_mat,
      xml_stream type xstring.
    START-OF-SELECTION.
    mat-matnr = '4711'.
    mat-maktx = 'Material & < Test'.
    CALL TRANSFORMATION ztest_st2
            SOURCE mat = mat
            RESULT XML xml_stream.
    CALL FUNCTION 'DISPLAY_XML_STRING'
      EXPORTING xml_string = xml_stream.
    Simple Transformation
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="MAT"/>
      <tt:template>
        <Leistungsschild>
            <CHARACT> MATNR </CHARACT>
            <CHARACT_DESCR> Materialnummer </CHARACT_DESCR>
            <VALUE tt:value-ref="MAT.MATNR"/>
            <CHARACT> MAKTX </CHARACT>
            <CHARACT_DESCR> Materialkurztext </CHARACT_DESCR>
            <VALUE tt:value-ref="MAT.MAKTX" />
        </Leistungsschild>
      </tt:template>
    </tt:transform>
    RESULT
    <?xml version="1.0" encoding="utf-8" ?>
    <Leistungsschild>
      <CHARACT>MATNR</CHARACT>
      <CHARACT_DESCR>Materialnummer</CHARACT_DESCR>
      <VALUE>4711</VALUE>
      <CHARACT>MAKTX</CHARACT>
      <CHARACT_DESCR>Materialkurztext</CHARACT_DESCR>
      <VALUE>Material & < Test</VALUE>   </Leistungsschild>

    Hi Sandra,
    First of all thaks for your quick answer to my problem.
    I see what you mean and get the same result, if I am using data-type string instead of xstring. But the recommendation in the XML-Books of SAP is to use XSTRING to save memory and circumflex problems between Codepages, when writing the XML-Stream to a filesystem.
    As you can see in the code abvoe I am using a SAP-FM to display the XML-Stream and this FM works only with XSTRING´s,
    that is one reason why I don´t understand that it displays it in the wrong way.
    Even the Debugger shows me for the XSTRING the wrong result. Does all that mean that the escaping will not be applyed if you are working with XSTING´s??

  • Simple transformation tt: utf-16 to utf-8 encoding

    Hi,
    (reposting here as no response in the ABAP General forum)
    I have a simple transformation the results of which are written to a file using open dataset. The XML in the file is appearing with encoding utf-16 but I need utf-8. I tried placing the following line in the transformation but it did not work:
    <xsl:output encoding="utf-8"/>
    The only way it works is if I use type xstring for the result of the transformation and not string. I then have to convert the xml from xstring to string before writing to the file. This works but I was wondering if there was an easier way to change the encoding of a simple transformation (tt:) ?????????
    Che

    Hi All,
    Reopening this old post, as I found that the same transformation and same program call results in an XML with utf-8 in a NW 7.30 system, while utf-16 in a NW 7.01 system!
    Any ideas why would it happen like this? And if there's anything that can be done to make sure the encoding remains same in both the systems?

  • Upload xml file to internal table only using simple transformation

    Hi Friends
    How to write transformation code for the following xml data.. Please let me know immedately if any one know..
    I have written as following but i encountered an eror staating -
    Iam facing the following error
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
    procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The goal was to access variable "ROOT1". However, this access was not
    possible.
    Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
    - <Negara>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>500</ZCODE>
    <ZDESC>Pening Lalat</ZDESC>
    <ZSAPCD>T1</ZSAPCD>
    </COUNTRY>
    </item>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>600</ZCODE>
    <ZDESC>Pening Lalat2</ZDESC>
    <ZSAPCD>T2</ZSAPCD>
    </COUNTRY>
    </item>
    </Negara>
    DATA : BEGIN OF XDATA OCCURS 0,
    STR(255) TYPE C,
    END OF XDATA.
    DATA: XMLUPL TYPE string .
    DATA : BEGIN OF ITAB OCCURS 0,
    MANDT(3) TYPE C,
    ZCODE(3) TYPE C,
    ZDESC(15) TYPE C,
    ZSAPCD(2) TYPE C,
    END OF ITAB.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = 'C:\country.xml'
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = XDATA.
    LOOP AT XDATA.
    CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
    ENDLOOP.
    CALL TRANSFORMATION ('Y_XMLCTRY')
    SOURCE XML XMLUPL
    result xml = ITAB[].
    BREAK-POINT.
    <?sap.transform simple?>
    <tt:transform template="temp1"
    xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT1"/>
    <tt:root name="ROOT2"/>
    <tt:template name="temp1">
    <Negara>
    <tt:loop ref=".ROOT1" name="i">
    <item>
    <tt:loop ref=".ROOT2" name="c">
    <COUNTRY>
    <MANDT>
    <tt:value ref="$c.nummer" />
    </MANDT>
    <ZCODE>
    <tt:value ref="$c.nummer" />
    </ZCODE>
    <ZDESC>
    <tt:value ref="$c.name" />
    </ZDESC>
    <ZSAPCD>
    <tt:value ref="$c.name" />
    </ZSAPCD>
    </COUNTRY>
    </tt:loop>
    </item>
    </tt:loop>
    </Negara>
    </tt:template>
    </tt:transform>
    Thanking You
    Devi

    Hi Friends
    How to write transformation code for the following xml data.. Please let me know immedately if any one know..
    I have written as following but i encountered an eror staating -
    Iam facing the following error
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
    procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The goal was to access variable "ROOT1". However, this access was not
    possible.
    Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
    - <Negara>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>500</ZCODE>
    <ZDESC>Pening Lalat</ZDESC>
    <ZSAPCD>T1</ZSAPCD>
    </COUNTRY>
    </item>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>600</ZCODE>
    <ZDESC>Pening Lalat2</ZDESC>
    <ZSAPCD>T2</ZSAPCD>
    </COUNTRY>
    </item>
    </Negara>
    DATA : BEGIN OF XDATA OCCURS 0,
    STR(255) TYPE C,
    END OF XDATA.
    DATA: XMLUPL TYPE string .
    DATA : BEGIN OF ITAB OCCURS 0,
    MANDT(3) TYPE C,
    ZCODE(3) TYPE C,
    ZDESC(15) TYPE C,
    ZSAPCD(2) TYPE C,
    END OF ITAB.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = 'C:\country.xml'
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = XDATA.
    LOOP AT XDATA.
    CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
    ENDLOOP.
    CALL TRANSFORMATION ('Y_XMLCTRY')
    SOURCE XML XMLUPL
    result xml = ITAB[].
    BREAK-POINT.
    <?sap.transform simple?>
    <tt:transform template="temp1"
    xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT1"/>
    <tt:root name="ROOT2"/>
    <tt:template name="temp1">
    <Negara>
    <tt:loop ref=".ROOT1" name="i">
    <item>
    <tt:loop ref=".ROOT2" name="c">
    <COUNTRY>
    <MANDT>
    <tt:value ref="$c.nummer" />
    </MANDT>
    <ZCODE>
    <tt:value ref="$c.nummer" />
    </ZCODE>
    <ZDESC>
    <tt:value ref="$c.name" />
    </ZDESC>
    <ZSAPCD>
    <tt:value ref="$c.name" />
    </ZSAPCD>
    </COUNTRY>
    </tt:loop>
    </item>
    </tt:loop>
    </Negara>
    </tt:template>
    </tt:transform>
    Thanking You
    Devi

  • Simple transformation : deserialize

    Hi,
    I have a simple transformation that works if I serialize table data, but it doesn't work when I wan't to deserialize.
    Here is my ABAP program that calls the transformation:
    TYPES: BEGIN OF flight,
            f_id TYPE p LENGTH 5,
            data TYPE c LENGTH 40,
          END OF flight,
          tt_flight TYPE STANDARD TABLE OF flight
                          WITH DEFAULT KEY.
    DATA: data1 TYPE flight.
    DATA: data2 TYPE flight.
    DATA: xml_string TYPE string.
    DATA: tab_data TYPE tt_flight.
    data1-f_id = '00001'.
    data1-data = 'before'.
    APPEND data1 to tab_data.
    data2-f_id = '00002'.
    data2-data = 'before'.
    APPEND data2 to tab_data.
    concatenate '<?xml version="1.0" encoding="iso-8859-2"?><XY><flights>'
                                       '<flight><id>11111</id><data>data1</data></flight>'
                                       '<flight><id>22222</id><data>data2</data></flight>'
                                       '</flights></XY>'
                into xml_string.
    CALL TRANSFORMATION ...
      SOURCE XML xml_string
      RESULT root = tab_data.
    And the transformation:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp_main">
      <tt:root name="ROOT"/>
      <tt:template name="temp_main">
        <XY>
          <flights>
            <tt:loop name="line" ref="ROOT">
              <flight>
                <id>
                  <tt:value ref="f_id"/>
                </id>
                <data>
                  <tt:value ref="data">
                </data>
              </flight>
            </tt:loop>
          </flights>
        </XY>
      </tt:template>
    </tt:transform>
    It won't update or append the content of the xml to my table.
    I would like to read many "<flight><id>.....</id><data>......</data></flight>" lines and write them into the table "tab_data".
    Could somebody please help me?
    Thanks in advance,
    Greg

    Hi Greg,
    try to address the root node with a period. Instead of
    <tt:loop name="line" ref="ROOT">
    use
    <tt:loop name="line" ref=".ROOT">
    Regards
    Stephan

  • Simple transformation with reference to ddic structures

    Hi, experts,
    we decide to use xml as the format when exchanging massive data with other applications. and we want to use simple transformation because according to the document it's more fast.
    actually our file structure is determined by certain ddic structures, one xml file main contain several ddic structures , and they are all flat one, not deep structure.
    the xml file may look like this:
    <data>
    <ddic1>[components of ddic structure 1 ]</ddic1>
    <ddic2>[components of ddic structure 2 ]</ddic2>
    </data>
    i am new to ST,i am wondering that is it possible to make the ST more easy with the help of ddic structure? do i still need to declare the components one by one in the ST program?
    BR.
    jun

    It only runs ok with 2 internal tables because of the way you set up the XML string.  It will run ok with 3 internal tables too.  If you strip out the '<C>' nodes or move the '<C>' nodes around, you'll see what I mean (move the C nodes to the last B node).  Each time you start a loop in a simple transformation, the internal table is initialized.  So, you need to form your sample XML string differently, declare your internal tables differently (nested), or use XSLT for a little more power.

  • Simple Transformation - XML to Internal Table Error

    I have a webservice call that returns XML.  I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing.  I have read through most posts regarding the topic but they're either too old or related to serialization.  There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root).  Below are some code snippets.  Any ideas on the problem with the XSLT template?  Thanks.
    Sample XML:
    <?xml version="1.0" encoding="utf-8" ?>
    <PrintVersionDataSet>
    <Result>
    <ReturnCode>W</ReturnCode>
    <ReturnMessage>There are reports with later version(s)</ReturnMessage>
    </Result>
    <Paperwork>
    <ReportCode>CVR</ReportCode>
    <ReportName>Cover Sheet</ReportName>
    <Version>2</Version>
    <PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime>
    </Paperwork>
    <Paperwork>
    <ReportCode>SPS</ReportCode>
    <ReportName>Sponsor Summary</ReportName>
    <Version>2</Version>
    <PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime>
    </Paperwork>
    </PrintVersionDataSet>
    XSLT Code:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="RESULT"/>
      <tt:root name="PAPERWORK"/>
      <tt:template>
        <PrintVersionDataSet>
          <Result tt:ref="RESULT">
            <ReturnCode>
              <tt:value ref="RETURNCODE"/>
            </ReturnCode>
            <ReturnMessage>
              <tt:value ref="RETURNMESSAGE"/>
            </ReturnMessage>
          </Result>
          <tt:deserialize>
            <tt:loop ref=".PAPERWORK">
              <Paperwork>
                <ReportCode>
                  <tt:value ref="REPORTCODE"/>
                </ReportCode>
                <ReportName>
                  <tt:value ref="REPORTNAME"/>
                </ReportName>
                <Version>
                  <tt:value ref="VERSION"/>
                </Version>
                <PrintedDateTime>
                  <tt:value ref="PRINTEDDATETIME"/>
                </PrintedDateTime>
              </Paperwork>
            </tt:loop>
          </tt:deserialize>
        </PrintVersionDataSet>
      </tt:template>
    </tt:transform>
    ABAP Call to Transform Data:
    TRY.
    CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC
          SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT
          RESULT RESULT     = LS_RESULT
                 PAPERWORK  = LT_PAPERWORK.
        CATCH CX_ROOT INTO ROOT_EXCEPTION.
          CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT
            RECEIVING
              RESULT = LV_MESSAGE.
      ENDTRY.

    Upon further inspection and testing with a simple file and program, I can see that the XML structure isn't quite correct for the loop process.  There needs to be a single <PAPERWORK> node, instead of one for each table line in the file.  This should allow the loop to execute properly after a slight adjustment to the XSLT template.

  • Simple Transformation from ABAP to XML and back

    Hi experts,
    Can anyone provide me a simple example of a 'simple transformation' that will convert and internal table with more than one column into XML via a simple transformation.
    I've spend days now reading SAP help and e-learning examples, but this just won't work and I am getting short dumps saying 'The goal was to access variable "ROOT". However, this access was notv possible.'
    Here is my ABAP:
    data: begin of struc,
               counter type i,
               aname type string,
               aname2 type string,
          end of struc.
    data: cnt_c type c.
    data: itab like table of struc with HEADER LINE,
          xml_string type xstring.
    do 3 times.
         move sy-index to: itab-counter, cnt_c.
         concatenate 'nameA' cnt_c into itab-aname.
         concatenate 'nameB' cnt_c into itab-aname2.
         append itab.
    enddo.
    CALL TRANSFORMATION Z_ST_TEST5
           SOURCE  ROOT = itab
           RESULT XML xml_string.
    CALL FUNCTION 'DISPLAY_XML_STRING'
      EXPORTING
        XML_STRING            = xml_string.
    skip 1.
    and here is my ST:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"/>
        <tt:template>
         <TABLE>
          <tt:loop ref=".ROOT" name="line">
            <ITEM>
              <counter>
                <tt:value ref="$line.aname" />
              </counter>
              <name>
                <tt:value ref="$line.aname" />
              </name>
              <name2>
                <tt:value ref="$line.aname2" />
              </name2>
            </ITEM>
          </tt:loop>
         </TABLE>
        </tt:template>
    </tt:transform>

    Figured it out. The interla tables used in teh call transformation statement can never have a header line.

  • Simple Transformation XML to ABAP   - error CX_ST_MATCH_ELEMENT

    Hi all,
    I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
    - <TABELLA>
    - <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
      <MANDT>300</MANDT>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
      <ID_ACT>1</ID_ACT>
      <DESC_ACT>ATTIVITÀ1</DESC_ACT>
      <LONG_TXT></LONG_TXT>
      <MAKE_BUY></MAKE_BUY>
      <WP></WP>
      <EVENTO_TECH></EVENTO_TECH>
      <TIPO_LEGAME></TIPO_LEGAME>
      <CONSEGNA></CONSEGNA>
      </ROW>
    - <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
      <MANDT>300</MANDT>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
      <ID_ACT>2</ID_ACT>
      <DESC_ACT>ATTIVITÀ2</DESC_ACT>
      <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT>
      <MAKE_BUY>M</MAKE_BUY>
      <WP></WP>
      <EVENTO_TECH></EVENTO_TECH>
      <TIPO_LEGAME></TIPO_LEGAME>
      <CONSEGNA></CONSEGNA>
      </ROW>
      </TABELLA>
      </asx:values>
      </asx:abap>
    my transformation is
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"></tt:root>
      <tt:root name="NETWORK"></tt:root>
      <tt:root name="OPERAZIONE"></tt:root>
      <tt:template>
      <abap>
        <values>
           <network>
               <tt:value ref="NETWORK"></tt:value>
           </network>
           <operazione>
               <tt:value ref="OPERAZIONE"></tt:value>
           </operazione>
           <tabella>
              <tt:loop ref=".ROOT" name="line">
                <mandt>
                  <tt:value ref="$line.mandt"></tt:value>
                </mandt>
                <network>
                  <tt:value ref="$line.network"></tt:value>
                </network>
                <OPERAZIONE>
                  <tt:value ref="$line.OPERAZIONE"></tt:value>
                </OPERAZIONE>
                <ID_ACT>
                  <tt:value ref="$line.ID_ACT"></tt:value>
                </ID_ACT>
                <DESC_ACT>
                  <tt:value ref="$line.DESC_ACT"></tt:value>
                </DESC_ACT>
                <LONG_TXT>
                  <tt:value ref="$line.LONG_TXT"></tt:value>
                </LONG_TXT>
                <MAKE_BUY>
                  <tt:value ref="$line.MAKE_BUY"></tt:value>
                </MAKE_BUY>
                <WP>
                  <tt:value ref="$line.WP"></tt:value>
                </WP>
                <EVENTO_TECH>
                  <tt:value ref="$line.EVENTO_TECH"></tt:value>
                </EVENTO_TECH>
                <TIPO_LEGAME>
                  <tt:value ref="$line.TIPO_LEGAME"></tt:value>
                </TIPO_LEGAME>
                <CONSEGNA>
                  <tt:value ref="$line.CONSEGNA"></tt:value>
                </CONSEGNA>
             </tt:loop>
            </tabella>
          </values>
        </abap>
      </tt:template>
    </tt:transform>
    when I execute my code
    the system dump with this error
    ST_MATCH_FAIL
    excep.  CX_ST_MATCH_ELEMENT
      TRY.
                CALL TRANSFORMATION ('ZT_NETWORK')
                SOURCE XML lv_xml_data_string
                RESULT  network = l_network
                        operazione = l_operazione
                        root = it_data_tmp.
              CATCH cx_sy_conversion_data_loss .
              CATCH cx_xslt_exception INTO xslt_error.
                xslt_message = xslt_error->get_text( ).
                WRITE:/ xslt_message .
            ENDTRY.
    Any help?
    thanks
    enzo

    Enzo Porcasi wrote:
    > I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
    >
    <?xml version="1.0" encoding="iso-8859-1" ?>
    >  <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    >  <asx:values>
    Your XML is strange, it looks like a mix of pdf form content (xfa) and identity transformation (asx).
    Could you explain more ?
    Anyway, I tried to find out the errors (not only cx_st_match_element, that was just a catch missing), it works with the following program. Here are the main issues I have found :
    - always catch exception class cx_st_error when you use simple transformations (it contains cx_st_match_element and all other simple transformation exceptions)
    - xml "asx:abap" and "asx:values" in your input XML are useless, they are only used by identity transformation ("ID"); you may keep them if you want, but I advise you to see why they are in the xml !
    - Use same case in your tags (if xml contains  in the transformation so that it corresponds to the input XML
    - I renamed all abap names with prefix ABAP_ so that to clearly differentiate xml tags and abap field names (so that it is more easy to understand, for every sdn reader; I hope it will help as I didn't find many threads in the forum).
    Simple transformation :
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ABAP_NETWORK"></tt:root>
      <tt:root name="ABAP_OPERAZIONE"></tt:root>
      <tt:root name="ABAP_TABELLA"></tt:root>
      <tt:template>
        <ROOT>
          <NETWORK>
            <tt:value ref=".ABAP_NETWORK"></tt:value>
          </NETWORK>
          <OPERAZIONE>
            <tt:value ref=".ABAP_OPERAZIONE"></tt:value>
          </OPERAZIONE>
          <TABELLA>
            <tt:loop ref=".ABAP_TABELLA" name="line">
              <ROW>
                <MANDT>
                  <tt:value ref="$line.ABAP_MANDT"></tt:value>
                </MANDT>
                <NETWORK>
                  <tt:value ref="$line.ABAP_NETWORK"></tt:value>
                </NETWORK>
                <OPERAZIONE>
                  <tt:value ref="$line.ABAP_OPERAZIONE"></tt:value>
                </OPERAZIONE>
                <ID_ACT>
                  <tt:value ref="$line.ABAP_ID_ACT"></tt:value>
                </ID_ACT>
                <DESC_ACT>
                  <tt:value ref="$line.ABAP_DESC_ACT"></tt:value>
                </DESC_ACT>
                <LONG_TXT>
                  <tt:value ref="$line.ABAP_LONG_TXT"></tt:value>
                </LONG_TXT>
                <MAKE_BUY>
                  <tt:value ref="$line.ABAP_MAKE_BUY"></tt:value>
                </MAKE_BUY>
                <WP>
                  <tt:value ref="$line.ABAP_WP"></tt:value>
                </WP>
                <EVENTO_TECH>
                  <tt:value ref="$line.ABAP_EVENTO_TECH"></tt:value>
                </EVENTO_TECH>
                <TIPO_LEGAME>
                  <tt:value ref="$line.ABAP_TIPO_LEGAME"></tt:value>
                </TIPO_LEGAME>
                <CONSEGNA>
                  <tt:value ref="$line.ABAP_CONSEGNA"></tt:value>
                </CONSEGNA>
              </ROW>
            </tt:loop>
          </TABELLA>
        </ROOT>
      </tt:template>
    </tt:transform>
    Program and XML included :
    REPORT  zsro2.
    DATA l_network TYPE string.
    DATA l_operazione TYPE string.
    DATA : BEGIN OF lt_data_tmp OCCURS 0,
             abap_mandt      TYPE string,
             abap_network    TYPE string,
             abap_operazione TYPE string,
             abap_id_act     TYPE string,
             abap_desc_act   TYPE string,
             abap_long_txt   TYPE string,
             abap_make_buy   TYPE string,
             abap_wp         TYPE string,
             abap_evento_tech TYPE string,
             abap_tipo_legame TYPE string,
             abap_consegna   TYPE string,
           END OF lt_data_tmp.
    DATA xslt_error TYPE REF TO cx_xslt_exception.
    DATA lo_st_error TYPE REF TO cx_st_error.
    DATA lv_xml_data_string TYPE string.
    DATA xslt_message TYPE string.
    DEFINE conc.
      concatenate lv_xml_data_string &1 into lv_xml_data_string.
    END-OF-DEFINITION.
    *conc '<?xml version="1.0" encoding="iso-8859-1" ?>'.
    *conc '<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'.
    *conc '  <asx:values>'.
    conc ' <ROOT>'.
    conc '    <NETWORK>E60000000000</NETWORK> '.
    conc '    <OPERAZIONE>0010</OPERAZIONE> '.
    conc '    <TABELLA>'.
    conc '      <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
    conc '        <MANDT>300</MANDT> '.
    conc '        <NETWORK>E60000000000</NETWORK> '.
    conc '        <OPERAZIONE>0010</OPERAZIONE> '.
    conc '        <ID_ACT>1</ID_ACT> '.
    conc '        <DESC_ACT>ATTIVITÀ1</DESC_ACT> '.
    conc '        <LONG_TXT></LONG_TXT> '.
    conc '        <MAKE_BUY></MAKE_BUY> '.
    conc '        <WP></WP> '.
    conc '        <EVENTO_TECH></EVENTO_TECH> '.
    conc '        <TIPO_LEGAME></TIPO_LEGAME> '.
    conc '        <CONSEGNA></CONSEGNA> '.
    conc '      </ROW>'.
    conc '      <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
    conc '        <MANDT>300</MANDT> '.
    conc '        <NETWORK>E60000000000</NETWORK> '.
    conc '        <OPERAZIONE>0010</OPERAZIONE> '.
    conc '        <ID_ACT>2</ID_ACT> '.
    conc '        <DESC_ACT>ATTIVITÀ2</DESC_ACT> '.
    conc '        <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT> '.
    conc '        <MAKE_BUY>M</MAKE_BUY> '.
    conc '        <WP></WP> '.
    conc '        <EVENTO_TECH></EVENTO_TECH> '.
    conc '        <TIPO_LEGAME></TIPO_LEGAME> '.
    conc '        <CONSEGNA></CONSEGNA> '.
    conc '      </ROW>'.
    conc '    </TABELLA>'.
    conc ' </ROOT>'.
    *conc '  </asx:values>'.
    *conc '</asx:abap>'.
    DATA lv_xml_data_string_2 TYPE string.
    TRY.
        CALL TRANSFORMATION zsro
              SOURCE
                XML lv_xml_data_string
              RESULT
                abap_network    = l_network
                abap_operazione = l_operazione
                abap_tabella    = lt_data_tmp[].
      CATCH cx_sy_conversion_data_loss .
      CATCH cx_st_error INTO lo_st_error.
        xslt_message = lo_st_error->get_text( ).
        WRITE:/ xslt_message .
      CATCH cx_xslt_exception INTO xslt_error.
        xslt_message = xslt_error->get_text( ).
        WRITE:/ xslt_message .
    ENDTRY.
    BREAK-POINT.

Maybe you are looking for

  • More problems while converting hyperlinks in word to pdf - missing first words

    I'm using Microsoft Office Word 2007 and Adobe Acrobat 9 Pro Extended (I think on Windows XP). If I have a word document with a working hyperlink when I convert it to PDF (using the Acrobat button in Word)I end up with a working hyperlink in the pdf

  • How much functionality in constructor?

    Hi Lets say I have a class 'schedule' which builds a schedule from a set of data and then holds that schedule for further processing. Which of these two options is better designed?: public class Schedule      public Schedule(SomeInputs inputs)       

  • Why did I stop receiving bill in the mail?

    Hello, I was wondering if I did anything to turn off paper bill payments. I haven't received my monthly payments in the mail for the past three months. Any help would be appreciated.

  • A Nice Feature

    Hi - It would be nice if you could opt not to have Aperture do the raw conversion. For example - opening in PS would have PS do the conversion. Bruce

  • Time Machine Fail

    Great. Here we go again. The box in quesiton is a newish (August '11) Mac Mini "Server" that shipped with Lion and has been through several mandatory rebuilds because of unrelated Apple-caused FAILS. It is running the latest 10.7.3 Lion Server with a