Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

XML to ABAP Problems with many attributes in one Tag (Simple Transform)

Former Member
0 Kudos

Hi

i have a XML-Dataset like this. (It's a sample, in originl there are more fields under <Faktura> and more <Faktura>.) My Problem is reading the Attributes.

<?xml version="1.0" encoding="utf-8"?>
<Fakturen>
<Faktura AVnr="123456789" Amt="100" Lang="1" Nr="1209" RechnungsTyp="B" Status="7" Waehrung="CHF" Year="2011" ZahlungsTyp="B"/>
</Faktura>
</Fakturen>

In the Tag "Faktura are many Attributes. How can i read this. I have try this with this code and many other variation. But it does not work.

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">
  <tt:root name="FAKTUREN" type="ddic:ZKSO_HRNET_INTERFACE"/>
  <tt:template>
    <Fakturen>
     <Faktura>
      <tt:attribute name="AVNR" value-ref=".FAKTUREN.FAKTURA.AVNR"/>
      <tt:attribute name="AMT" value-ref=".FAKTUREN.FAKTURA.AMT"/>
      <tt:attribute name="LANG" value-ref=".FAKTUREN.FAKTURA.LANG"/>
      <tt:attribute name="NR" value-ref=".FAKTUREN.FAKTURA.NR"/>
      <tt:attribute name="RECHNUNGSTYP" value-ref=".FAKTUREN.FAKTURA.RECHNUNGSTYP"/>
      <tt:attribute name="STATUS" value-ref=".FAKTUREN.FAKTURA.STATUS"/>
      <tt:attribute name="WAEHRUNG" value-ref=".FAKTUREN.FAKTURA.WAEHRUNG"/>
      <tt:attribute name="YEAR" value-ref=".FAKTUREN.FAKTURA.YEAR"/>
     </Faktura>
    </Fakturen>
  </tt:template>
</tt:transform>

Thanks for help

Stefan

Edited by: Franziska Madl on Mar 2, 2011 2:39 PM

6 REPLIES 6

Former Member
0 Kudos

Hi

I had done this way back using a function module SMUM_XML_PARSE. You get all the XML tags in the internal table under the tables parameter. Somehow, looping and tweaking through the internal table records I managed to fulfill my requirement. Check if you get the desired result.

Regards,

Rupesh Mhatre

Edited by: rumhat on Mar 2, 2011 3:06 PM

0 Kudos

Hi

Thank you for your answer. The function module SMUM_XML_PARSE is a good way to Read a XML. Now I have found the Correct way with simple transfer and it works with an array too.

many regards

Stefan

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">
  <tt:root name="FAKTUREN" type="ddic:ZKSO_HRNET_INTERFACE"/>
  <tt:template>
    <Fakturen>
      <tt:loop ref=".FAKTUREN.FAKTURA">
        <Faktura>
            <tt:attribute name="AVnr" value-ref="AVNR"/>
            <tt:attribute name="Amt" value-ref="AMT"/>
            <tt:attribute name="Lang" value-ref="LANG"/>
            <tt:attribute name="Nr" value-ref="NR"/>
            <tt:attribute name="RechnungsTyp" value-ref="RECHNUNGSTYP"/>
            <tt:attribute name="Status" value-ref="STATUS"/>
            <tt:attribute name="Waehrung" value-ref="WAEHRUNG"/>
            <tt:attribute name="Year" value-ref="YEAR"/>
            <tt:attribute name="ZahlungsTyp" value-ref="ZAHLUNGSTYP"/>
        </Faktura>
      </tt:loop>
    </Fakturen>
  </tt:template>
</tt:transform>

0 Kudos

The forum rule says, if a post is helpful you should award points to the person posting it.

Lukas_Weigelt
Active Contributor
0 Kudos

Hi,

in my opinion $FAKTURA.<whatever> might work, or maybe $FAKTUREN.FAKTURA.<whatever>. Either way you need to put a "$" in front.

Other than that you should check out the wiki and Tobias Trapp's Blog (Expert in Serialization/Deserialization) for more information.

hope it helps a bit,

regards, Lukas

0 Kudos

Hi Lukas

the way with the $FAKTURA did not work. But I have found another solution. See my answer to Rupesh Mhatre

Best regards

Stefan

0 Kudos

Franziska

Please, tell me what was the solution that you find for the subject

Thank you

regards

Dario.