Simple Transformation XML to ABAP Content of tag with subtrees to string field

Hi,
I have an  requirement in which I have to do a transformation from an XML file to an structure.
I need get the value of a tag that have subtrees and move that to a field in my structure.
Example:
<TAG1>value1</TAG1>
<TAG2>value2</TAG2>
<TAG3>
     <TAG4>value4</TAG4>
     <TAG5>value5</TAG5>
</TAG3>
Result expected in ABAP Structure:
field1 -> tag1
field2 -> tag2
field3 -> <TAG4>value4</TAG4><TAG5>value5</TAG5>
The contents of the tag TAG3 is variable, so I want to store it as a string.
Can I make this with Simple Transformation?
In my tests I can move only the value of each child tag for the given field structure.
This syntax dont work:
<TAG3 tt:value-ref="STRUCTURE.FIELD3"/>
Thanks and Regards,
Miguel Motta

Hi Miguel
Have a look at below snippets. Here I have tried to escape the text inside TAG3 so that it gets treated as single node during transformation.
ABAP code
DATA: BEGIN OF result,
        col1 TYPE string,
        col2 TYPE string,
        col3 TYPE string,
      END OF result.
DATA: xml_string TYPE string VALUE
'<ROOT> <TAG1>value1</TAG1> <TAG2>value2</TAG2> <TAG3> <TAG4>value4</TAG4> <TAG5>value5</TAG5> </TAG3> </ROOT>',
      part1 TYPE string,
      part2 TYPE string,
      part3 TYPE string.
*   Escape the text inside TAG3 tag
FIND REGEX '(.*<TAG3>)(.*)(</TAG3>.*)' IN xml_string SUBMATCHES part1 part2 part3.
IF sy-subrc EQ 0.
  part2 = escape( val = part2 format = cl_abap_format=>e_xml_text ).
*      REPLACE ALL OCCURRENCES OF '<' IN part2 WITH '&lt;'.
*      REPLACE ALL OCCURRENCES OF '>' IN part2 WITH '&gt;'.
  xml_string = part1 && part2 && part3.
ENDIF.
TRY.
* Display xml
    cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).
* Deserialization
    CALL TRANSFORMATION zmtest
      SOURCE XML xml_string
      RESULT para = result.
* Check result
    WRITE:/ 'COL1=', result-col1,
          / 'COL2=', result-col2,
          / 'COL3=', result-col3.
  CATCH cx_st_error.
* Error handling
    MESSAGE 'Error in Simple Transformation'
            TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
Transformation code
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp" version="0.1">
   <tt:root name="PARA"/>
   <tt:template name="temp">
     <ROOT>
       <TAG1>
         <tt:value ref="PARA.COL1"/>
       </TAG1>
       <TAG2>
         <tt:value ref="PARA.COL2"/>
       </TAG2>
       <TAG3>
         <tt:value ref="PARA.COL3"/>
       </TAG3>
     </ROOT>
   </tt:template>
</tt:transform>

Similar Messages

  • 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.

  • Simple transformation XML to ABAP, runtime error: CX_ST_REF_ACCESS

    Hi, all experts,
    I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
    Can anybody help me to fix the problem? Thanks very much. It's urgent.
    The code of transformation like this:
    <tt:root name="DATA"/>
      <tt:template>
        <node>
          <tt:deserialize>
            <tt:loop ref=".DATA" name="mdr_data">
              <tt:attribute name="type">
                <tt:value ref="$mdr_data.lf_type"/>
              </tt:attribute>
              <tt:attribute name="objid">
                <tt:value ref="$mdr_data.lf_objid"/>
              </tt:attribute>
              <tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
              <tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
            </tt:loop>
          </tt:deserialize>
        </node>
      </tt:template>
    The Data-structure in my Report:
    DATA: BEGIN OF ls_mdr_data,
            lf_type TYPE /ehr/ct_dt_bo_type,
            lf_objid TYPE realo,
            lf_name TYPE stext,
            lf_short TYPE short_d,
          END OF ls_mdr_data,
         lt_result_data like TABLE OF ls_mdr_data.
    If I call the transformation use the XML-String like:
    <node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
    I got the  error  CX_ST_REF_ACCESS:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not  caught and
        therefore caused a runtime error.
        The reason for the exception is:
        The goal was to access variable "LF_TYPE". However, this access was not
        possible.

    Hi, all experts,
    I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
    Can anybody help me to fix the problem? Thanks very much. It's urgent.
    The code of transformation like this:
    <tt:root name="DATA"/>
      <tt:template>
        <node>
          <tt:deserialize>
            <tt:loop ref=".DATA" name="mdr_data">
              <tt:attribute name="type">
                <tt:value ref="$mdr_data.lf_type"/>
              </tt:attribute>
              <tt:attribute name="objid">
                <tt:value ref="$mdr_data.lf_objid"/>
              </tt:attribute>
              <tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
              <tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
            </tt:loop>
          </tt:deserialize>
        </node>
      </tt:template>
    The Data-structure in my Report:
    DATA: BEGIN OF ls_mdr_data,
            lf_type TYPE /ehr/ct_dt_bo_type,
            lf_objid TYPE realo,
            lf_name TYPE stext,
            lf_short TYPE short_d,
          END OF ls_mdr_data,
         lt_result_data like TABLE OF ls_mdr_data.
    If I call the transformation use the XML-String like:
    <node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
    I got the  error  CX_ST_REF_ACCESS:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not  caught and
        therefore caused a runtime error.
        The reason for the exception is:
        The goal was to access variable "LF_TYPE". However, this access was not
        possible.

  • 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.

  • Help Please ! -- transform XML to HTML using xslt tag in JSP

    Hello,
    I have problem to do XSL transform in JSP.
    I have an XSL : test.xsl
    I have an XML : test.xml
    In JSP I have:
    <x:xslt media="html" xml="test.xml">
    <x:stylesheet media="html" uri="test.xsl" />
    </x:xslt>
    But It doesn't work the way it suppose to. What is wrong in my code ? I followed the URL http://e-docs.bea.com/wls/docs81/xml/xml_apps.html
    Thanks in advance,
    Christina

    Basically:
        try{
          //Setting up parameters.
          xml=new StreamSource(new File(xmlInput));
          xsl=new StreamSource(new File(xslInput));
          baos=new ByteArrayOutputStream();
          htmlResult=new StreamResult(baos);
          //Transform input(xml, xsl) onto html output.
          TransformerFactory tfactory=TransformerFactory.newInstance();
          Transformer transformer=tfactory.newTransformer(xsl);
          transformer.transform(xml, htmlResult);
          baos.writeTo(out);
          //System.err.println(htmlResult.getOutputStream().toString());
        catch(...){
        }I havent tested and I havent use this for a while, but I hope this can serve as a staring point.
    Regards,
    OO

  • Problems in transforming XML to HTML using HP-UX with Netscape Enterprise Server 4.0 sp3

    Hi,
    Has anyone ever had any problem using XML in NES 4.0 sp3?
    I'm using the libraries com.sun.xml.parser, com.sun.xml.tree, javax.xml.transform.
    The html is being created but is not being returned.
    (it is not showed in browser)
    This same xml application works well in Solaris with Iplanet Web Server 4.1, but it is not working in HP-UX with Netscape Enterprise Server 4.0 sp3.
    I'm entirely lost. I don't know if there is a bug in this version (NES 4.0) or if I need other xml libraries or it is a problem of JRE version.
    Any comments will be appreciate.
    Thanks

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Norbert Clavaux ([email protected]):
    Hi,
    Last year we built a complete new website, based on XML/XSL.
    We assumed all browsers would cope with XSL by now, but that was far to optimistic.
    Our company planned to launch the new site this december, but XSL is giving us some major problems:
    *** All our customers are obliged to use Internet Explorer 4/5.x. Some don't like that at all: they stick to Netscape.
    *** IE users have to download and install the MS-XSL parser. At our pilotsites this is giving a lot of trouble and frustration.
    I heard that it is possible to do the parsing at the serverside, using XSLT, creating HTML.
    HOW CAN WE INSTALL / IMPLEMENT THIS OPTION IN OUR CONFIGURATION?
    (PL/SQL / IAS 9i / Sun Solaris / Oracle 8.1.2)
    Thanks in advance,
    Norbert Clavaux
    Nederlandse Bibliotheek Dienst
    The Netherlands<HR></BLOCKQUOTE>
    You could use DB Prism / Cocoon CMS.
    This CMS is built on top of Apache Cocoon Framework and DB Prism servlet engine.
    This CMS stores the assets in the DB (CLOB) and applys the stylesheet at runtime.
    If you need more information about this CMS look at is free.
    This CMS builts the DB Prism web site at www.plenix.com/dbprism/
    Best regards, Marcelo.

  • Standard Transformation XML to ABAP

    Is there a sense to read bigger xml with standard transformations into an internal table?
    Or is it at least to restrictive?
    I can't find a real good documentation of it. Also I can't find out which way is the best to get my xml into a table.
    Can somebody give me a hint?
    Edited by: Rob Burbank on Feb 2, 2010 3:04 PM

    Does somebody know:
    I have 3 Elements in my XML.
    In Standard Transformation I know only the first element.
    The problem is, that the standard transformation does not ignore the other 2.
    <X>
    </A>
    </B>
    </C>
    </X>
    I get an Exception that a closing Tag for X is expected after processing A.
    Is there a way to make the standard transformation less sensitive?

  • 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.

  • Optional attributes in XML to ABAP transformation

    Hi,
    I have to deserialize (transformation xml to abap) an xml input file.
    I want to use SAP ST (Simple Transformations).
    This xml format is using attributes
    Such attributes can be transformed in ST with
    <tt:attribute name="item_id" value-ref="MATNR"/>
    I realized 2 problems:
    1. If the xml file does not contain every attribute which is in the transformation.
    This can be solved by tt:cond
    Sample
              <tt:cond>
                <tt:attribute name="uom" value-ref="BASE_UOM"/>
              </tt:cond>
    Now attribute uom is optional. Without the tt:cond the ST prragrom would throw exception if it is not in the file.
    2. If the xml file contains an attribute which is not used in the transformation.
    I tried to use tt:skip but it is not working for "<tt:attribute name= ... value-ref=... name" but only for "<tt:value-ref=...".
    I only want to get the values I need out of the parameter list.
    How can I achieve this without defining a transformation for every parameter in the xml file?
    Thanks and regards
    Michael

    Hi,
    thanks for reply. It took me into the right direction. You have to distinguish between elements (ordered structured nodes) and attributes (unordered structured nodes). In my case they are using attributes for the values of a material master.
    Here is a snippet (sample of the XML):
    <?xml version="1.0" encoding="utf-8"?>
    <TcPLMXML>
      <TCifEngPart item_id="1-3000-3630-00"
                   seMaterialType="HALB"
                   uom="ST"
                   seWeight="2000.0" seWeightUnit="KG">
      </TCifEngPart>
      <TCifEngPart item_id="1-30000-41002-00"
                   seMaterialType="HALB"
                   uom="ST"
      </TCifEngPart>
    </TcPLMXML>
    and my transformation:
          <tt:loop ref="MATERIAL_LIST">
            <TCifEngPart>
              <tt:attribute name="item_id" value-ref="MATNR"/>
              <tt:attribute name="object_name" value-ref="MATL_DESC"/>
              <tt:attribute name="seMaterialType" value-ref="MATL_TYPE"/>
              <tt:attribute name="uom" value-ref="BASE_UOM"/>
              <tt:cond>
                 <tt:attribute name="seLength" value-ref="LENGTH"/>
                 <tt:attribute name="seWidth" value-ref="WIDTH"/>
                 <tt:attribute name="seHeight" value-ref="HEIGHT"/>
              </tt:cond>
              <tt:skip>
                 <tt:attribute name="seWeight" />
                 <tt:attribute name="seVolume" />
              </tt:skip>
            </TCifEngPart>
          </tt:loop>
    Length, width and hight are optional in the XML and will be transferred to the corresponding SAP fields if they are in the input file Weight and volume will be ignored.
    This means all attributes I don't need I have to put within the tt:skip.
    Without this skip the transformation throws an error.
    In consequence if the partner system add new attributes I have to enhance the transformation in SAP.
    Is there any other way?

  • Simple transformation formatting

    Dear Expert,
    I would like to know how can I format my transformation result using simple transformation. I have an attribute that is supposed to display a date in the format YYYYMMDD. However, the default format is YYYY-MM-DD. How can I change this behavior in simple transformation? Thanks!
    Regards,
    Alex

    Hey Alex,
    do you have a solution already? I have the same problem, the format of the date in the XML-File is "20140101" and I can´t transform it with Simple Transformation to the ABAP Type DATS which waits for "2014-01-01" or "2014.01.01".
    the Transformation looks like this in the moment:
    <DATE tt:value-ref="DATE"/>
    The ABAP type of the field DATE is DATS. And the XML looks at this part like this:
    <DATE>20131201</DATE>
    Regards,
    Christoph

  • How to skip XML tags in Simple transformation

    Hi,
    I am trying to convert an XML file to ABAP code using Simple Transformations.
    I tired converting a small XML file to ABAP using it and it worked fine.
    The problem is that the number of tags in the XML file I now want to parse is huge (over 200).
    Is there any way that for the tag in XML corresponding tag is not created in ST? Is there any conditional tag to achieve this?
    Also, is Simple Transformation a better way of parsing in such a scenario over XSLT and DOM parser?
    Thanks and Regards,
    Neha
    Edited by: Neha Anand on Jun 2, 2008 1:19 PM

    Hi Raja,
    I have already looked through the code snippets and I am able to write a CALL TRANSFORMATION.
    I want to find out if the number of tags is huge then if there is any way that some tags can be skipped for matching tags in XML which anyhow I dont need for manipulation.
    Thanks and Regards,
    Neha

  • Create xml tag dynamically within simple transformation

    Hi all together,
    I'm faceing the following problem:
    There is a internal table provided, consisting of name/value-pairs. Something like
    ls_struc-name = 'NAME1'.
    ls_struc-value = 'XYZ'.
    append ls_struc to lt_struc
    ls_struc-name = 'CITY1'.
    ls_struc-value = 'Munich'.
    append ls_struc to lt_struc
    and so on.
    I have to create this XML (with simple transformation):
    <NAME1>XYZ</NAME1>
    <CITY1>Munich</CITY1>
    Everythings works fine so far (tables, values etc.), but I have problems with creating the XML-Tag, e.g <NAME1> from "$line.name" within the transformation. I don't have any information about the data structure (therefore "call transaction id" does not work).
    Any hint is useful!!!
    Best regards,
    Thomas

    Exaple program for creating XML file from abap
    REPORT  z_xit_xml_dom_create.
      TYPE-POOLS: ixml.
      TYPES: BEGIN OF xml_line,
              data(256) TYPE x,
             END OF xml_line.
      DATA: l_ixml            TYPE REF TO if_ixml,
            l_streamfactory   TYPE REF TO if_ixml_stream_factory,
            l_ostream         TYPE REF TO if_ixml_ostream,
            l_renderer        TYPE REF TO if_ixml_renderer,
            l_document        TYPE REF TO if_ixml_document.
      DATA: l_element_flights TYPE REF TO if_ixml_element,
            l_element_airline TYPE REF TO if_ixml_element,
            l_element_flight  TYPE REF TO if_ixml_element,
            l_element_from    TYPE REF TO if_ixml_element,
            l_element_to      TYPE REF TO if_ixml_element,
            l_element_dummy   TYPE REF TO if_ixml_element,
            l_value           TYPE string.
      DATA: l_xml_table       TYPE TABLE OF xml_line,
            l_xml_size        TYPE i,
            l_rc              TYPE i.
      DATA: lt_spfli          TYPE TABLE OF spfli.
      DATA: l_spfli           TYPE spfli.
      START-OF-SELECTION.
    *   Fill the internal table
        SELECT * FROM spfli INTO TABLE lt_spfli.
    *   Sort internal table
        SORT lt_spfli BY carrid.
    *   Start filling xml dom object from internal table
        LOOP AT lt_spfli INTO l_spfli.
          AT FIRST.
    *       Creating a ixml factory
            l_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
            l_document = l_ixml->create_document( ).
    *       Fill root node with value flights
            l_element_flights  = l_document->create_simple_element(
                        name = 'flights'
                        parent = l_document ).
          ENDAT.
          AT NEW carrid.
    *       Create element 'airline' as child of 'flights'
            l_element_airline  = l_document->create_simple_element(
                        name = 'airline'
                        parent = l_element_flights  ).
    *       Create attribute 'code' of node 'airline'
            l_value = l_spfli-carrid.
            l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).
    *       Create attribute 'name' of node 'airline'
            SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.
            l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).
          ENDAT.
          AT NEW connid.
    *       Create element 'flight' as child of 'airline'
            l_element_flight  = l_document->create_simple_element(
                        name = 'flight'
                        parent = l_element_airline  ).
    *       Create attribute 'number' of node 'flight'
            l_value = l_spfli-connid.
            l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).
          ENDAT.
    *     Create element 'from' as child of 'flight'
          CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.
          l_element_from  = l_document->create_simple_element(
                      name = 'from'
                      value = l_value
                      parent = l_element_flight  ).
    *     Create attribute 'airport' of node 'from'
          l_value = l_spfli-airpfrom.
          l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).
    *     Create element 'to' as child of 'flight'
          CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.
          l_element_to  = l_document->create_simple_element(
                      name = 'to'
                      value = l_value
                      parent = l_element_flight  ).
    *     Create attribute 'airport' of node 'from'
          l_value = l_spfli-airpto.
          l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).
    *     Create element 'departure' as child of 'flight'
          l_value = l_spfli-deptime.
          l_element_dummy  = l_document->create_simple_element(
                      name = 'departure'
                      value = l_value
                      parent = l_element_flight ).
    *     Create element 'arrival' as child of 'flight'
          l_value = l_spfli-arrtime.
          l_element_dummy  = l_document->create_simple_element(
                      name = 'arrival'
                      value = l_value
                      parent = l_element_flight ).
    *     Create element 'type' as child of 'flight'
          CASE l_spfli-fltype.
            WHEN 'X'.
              l_value = 'Charter'.
            WHEN OTHERS.
              l_value = 'Scheduled'.
          ENDCASE.
          l_element_dummy  = l_document->create_simple_element(
                      name = 'type'
                      value = l_value
                      parent = l_element_flight ).
        ENDLOOP.
        IF sy-subrc NE 0.
          MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.
        ENDIF.
    *   Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
    *   Connect internal XML table to stream factory
        l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
    *   Rendering the document
        l_renderer = l_ixml->create_renderer( ostream  = l_ostream
                                              document = l_document ).
        l_rc = l_renderer->render( ).
    *   Saving the XML document
        l_xml_size = l_ostream->get_num_written_raw( ).
        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            bin_filesize = l_xml_size
            filename     = 'c:\temp\flights.xml'
            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.

  • 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.

  • ABAP Simple Transformation - How to save XML to file with CL_FX_WRITER?

    Hello!
    When calling a Simple Transformation program for transformation from ABAP to XML, it is possible to specify RESULT XML rxml as a class reference variable of type CL_FX_WRITER, which points to an XML writer.
    How to handle CL_FX_WRITER in order to save XML to a file?
    Thanks and regards,
    Andrey

    Hallo Rainer!
    Many thanks. I have checked the profile parameter ztta/max_memreq_MB and it is set to 2048 MB in the development system. I hope, that won't be less on the client's machine. The only thing I did not clearly explained, is that I need to write XML data to the server. I am so sorry. Downloading to the local PC is very helpful for me also, but only for the test purposes.
    Regards,
    Andrey

  • 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:\

Maybe you are looking for

  • Problem on degital sign the PDF document i.e ROC forms

    For additional help, reach us at http://helpx.adobe.com/contact.html General Info Chat start time Jan 6, 2015 10:06:03 PM PST Chat end time Jan 6, 2015 10:14:00 PM PST Duration (actual chatting time) 00:07:57 Operator Imran Chat Transcript info: Than

  • Help required on 'FOR ALL ENTRIES IN'

    I am using this query: SELECT vguid qausp   INTO TABLE tb_qualif   FROM vlcadddata   FOR ALL ENTRIES IN tb_distmode1   WHERE vguid = tb_distmode1-vguid   AND aqual = 'ASPT'. Now if the internal table contains no data tb_distmode1 then the query is gi

  • Greying out variable on the seclection screen

    Hello Experts, I need to grey out a variable ("X") on the selection screen in our BI7.0 system. The variable has been used in the query but as per the bussiness requirements this variable should not be changed by the end user. Currently, as per the s

  • Show item info does not show on all files

    I need that "show item info" very much, because it shows, how many sec each of my video clips are. When I have a folder with many video clips in it, about 3/4 shows the item info (sec length of clip) but about 1/4 it does not. It would help me a lot

  • IPAD2 and IOS 8

    I like many others on this site, have noted that their IPAD 2 has basically become unusable with IOS 8. Each new upgrade on IOS 8 has made it worse. The latest 8.1 has now slowed the IPAD 2 down to the point where there only use are as boat anchors.