Skip to Content
author's profile photo
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • author's profile photo
    Former Member
    Posted on Mar 02, 2011 at 02:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 02, 2011 at 02:09 PM

    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

    Add comment
    10|10000 characters needed characters exceeded