Application Development and Automation 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: 
Read only

XML to internal table

Former Member
0 Likes
627

Hi,

I am on 4.6 C. Call Transformation is not available here.

I have an XML file with deep structure with nodes/subnodes.

I have to convert the file to an internal table with matching deep structure.

I have seen a program that works in reverse- i.e. converts internal table with deep structure to XML and it seems to work fine in 4.6 C.

Does anybody have a program that creates internal table from XML?

Any help would be highly appreciated

4 REPLIES 4
Read only

Former Member
0 Likes
583

Hi,

Please try to use FM SMUM_XML_PARSE.

This FM will upload an XMl file into an internal table.

Regards,

Ferry Lianto

Read only

0 Likes
583

Thanks Ferry,

But the FM SMUM_XML_PARSE not available in 4.6C

Any other ideas?

Read only

Former Member
0 Likes
583

sudhir,

See the below links, this is useful for you

/people/tobias.trapp/blog/2006/10/06/xml-processing-in-abap-part-9-150-abap-processing-using-xslt

http://searchtechtarget.techtarget.com/generic/0,295582,sid21_gci1207657,00.html

http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/15ecdf90-0201-0010-d792-941a3c3c...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/d-f/from%20x...

**************************************************************

XLST program code (YSIMPLEXMLTOITAB)

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

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

<xsl:output indent="yes"/>

<xsl:template match="QfiData">

<I_DATA>

<xsl:for-each select="Materials">

<I_DATA1>

<MATERIAL>

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

</MATERIAL>

<CONDITIONRATE>

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

</CONDITIONRATE>

<VALIDFROM>

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

</VALIDFROM>

<VALIDTO>

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

</VALIDTO>

<REGIONID>

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

</REGIONID>

<MATERIALID>

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

</MATERIALID>

</I_DATA1>

</xsl:for-each>

</I_DATA>

</xsl:template>

</xsl:stylesheet>

Program to test it.

REPORT y_test_xml_tran.

TYPES: BEGIN OF i_det,

Material(10),

ConditionRate(16) type p decimals 2 ,

ValidFrom(10) ,

ValidTo(10) ,

RegionID(3) ,

MaterialID(10) ,

end of i_det .

DATA: i_data TYPE TABLE OF i_det.

data: wa like line of i_data .

DATA: xml_string TYPE string .

DATA: xslt_error TYPE REF TO cx_xslt_exception,

xslt_message TYPE string .

CLEAR xml_string .

CONCATENATE

`<?xml version="1.0" encoding="utf-8"?>`

`<QfiData xmlns:xsl="http://www2.siemens.nl/qfiservice/QfiData.xsd">`

`<Materials>`

`<Material>463581</Material>`

`<ConditionRate> 2.44</ConditionRate>`

`<ValidFrom>20060208</ValidFrom>`

`<ValidTo>99991231</ValidTo>`

`<RegionID>48</RegionID>`

`<MaterialID>36294</MaterialID>`

`</Materials>`

`<Materials>`

`<Material>463582</Material>`

`<ConditionRate> 2.44</ConditionRate>`

`<ValidFrom>20060208</ValidFrom>`

`<ValidTo>99991231</ValidTo>`

`<RegionID>48</RegionID>`

`<MaterialID>36295</MaterialID>`

`</Materials>`

`</QfiData>`

INTO xml_string .

TRY .

CALL TRANSFORMATION (`YSIMPLEXMLTOITAB`)

SOURCE XML xml_string

RESULT i_data = i_data.

CATCH cx_xslt_exception INTO xslt_error.

xslt_message = xslt_error->get_text( ).

ENDTRY.

***************************************************************

Don't forget to reward if useful

Read only

Former Member
0 Likes
583

Thanks Muralikrishna.

There is no 'call transformation' in 4.6 C

Do you have any more suggestions?