Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Reading XML file to ABAP internal table

Hi all,

Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.

below is the XML file.

===========================================================================

- <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">

- <PIX>

<TransactionType>605</TransactionType>

<TransactionCode>98</TransactionCode>

<TransactionNumber>6888965</TransactionNumber>

<SequenceNumber>40001</SequenceNumber>

- <SKUDefinition>

<Company>GZL</Company>

<Division>BMD</Division>

<Season />

<SeasonYear />

<Style>ORT002A</Style>

<StyleSuffix />

<Color>K13</Color>

<ColorSuffix />

<SecDimension />

<Quality />

<SizeRangeCode />

<SizeDesc>M</SizeDesc>

<SkuID>200140577</SkuID>

</SKUDefinition>

</PIX>

</PIXBridge>

=================================================================

and my Transformation code is as below

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>

<xsl:strip-space elements="*"/>

<xsl:template match="/">

<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

<asx:values>

<IPIX>

<xsl:apply-templates select="//PIX"/>

</IPIX>

</asx:values>

</asx:abap>

</xsl:template>

<xsl:template match="PIX">

<item>

<TRANSACTIONTYPE>

<xsl:value-of select="TransactionType"/>

</TRANSACTIONTYPE>

<TRANSACTIONCODE>

<xsl:value-of select="TransactionCode"/>

</TRANSACTIONCODE>

<TRANSACTIONNUMBER>

<xsl:value-of select="TransactionNumber"/>

</TRANSACTIONNUMBER>

<SEQUENCENUMBER>

<xsl:value-of select="SequenceNumber"/>

</SEQUENCENUMBER>

<SKUDEFINITION>

<COMPANY>

<xsl:value-of select="Company"/>

</COMPANY>

<DIVISION>

<xsl:value-of select="Division"/>

</DIVISION>

<SEASON/>

<SEASONYEAR/>

<STYLE>

<xsl:value-of select="Style"/>

</STYLE>

<STYLESUFFIX/>

<COLOR>

<xsl:value-of select="Color"/>

</COLOR>

<COLORSUFFIX/>

<SECDIMENSION/>

<QUANTITY/>

<SIZERANGECODE/>

<SIZEDESC>

<xsl:value-of select="SizeDesc"/>

</SIZEDESC>

<SKUID>

<xsl:value-of select="SkuID"/>

</SKUID>

</SKUDEFINITION>

</item>

</xsl:template>

When i run my program i am getting the values only till the sequence number part and im not getting any values that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>

I need help to sort this , kindly help me in this.

regs,

raja

Tags:
Former Member
Former Member replied

Hello Raja

You need to "point" the XML parser to the SKUDefinition node.

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <asx:values>
        <IPIX>
          <xsl:apply-templates select="//PIX"/>
        </IPIX>
      </asx:values>

    </asx:abap>
  </xsl:template>

  <xsl:template match="PIX">
    <item>
      <TRANSACTIONTYPE>
        <xsl:value-of select="TransactionType"/>
      </TRANSACTIONTYPE>

      <TRANSACTIONCODE>
        <xsl:value-of select="TransactionCode"/>
      </TRANSACTIONCODE>

      <TRANSACTIONNUMBER>
        <xsl:value-of select="TransactionNumber"/>
      </TRANSACTIONNUMBER>

      <SEQUENCENUMBER>
        <xsl:value-of select="SequenceNumber"/>
      </SEQUENCENUMBER>

      <!-- NOTE: this FOR-EACH point to the SKUDefinition node -->
      <xsl:for-each select="SKUDefinition">
        <SKUDEFINITION>
          <COMPANY>
            <xsl:value-of select="Company"/>
          </COMPANY>
          <DIVISION>
            <xsl:value-of select="Division"/>
          </DIVISION>
          <SEASON/>
          <SEASONYEAR/>
          <STYLE>
            <xsl:value-of select="Style"/>
          </STYLE>
          <STYLESUFFIX/>
          <COLOR>
            <xsl:value-of select="Color"/>
          </COLOR>
          <COLORSUFFIX/>
          <SECDIMENSION/>
          <QUANTITY/>
          <SIZERANGECODE/>
          <SIZEDESC>
            <xsl:value-of select="SizeDesc"/>
          </SIZEDESC>
          <SKUID>
            <xsl:value-of select="SkuID"/>
          </SKUID>
        </SKUDEFINITION>
      </xsl:for-each>


    </item>
  </xsl:template>


</xsl:transform>

Regards
  Uwe

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question