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: 

Internal table to xml format

Former Member
0 Kudos

Hai all,

I have to convert internal table to xml format. Here is the sample Xml format.

<ACES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ACES_DLR.xsd">

<INVOICE-HEADER>

<INVOICE-PARTICULARS SL-NO="1">

<INVOICE-NUMBER>12365897777777771541</INVOICE-NUMBER>

<INVOICE-DATE>15/11/2009</INVOICE-DATE>

<INVOICE-ITEMS>

<CETSH-NUMBER>01019020</CETSH-NUMBER>

<QUANTITY-CODE>U</QUANTITY-CODE>

<QUANTITY>1235.00</QUANTITY>

<AMOUNT-OF-DUTY-INVOLVED>226584.00</AMOUNT-OF-DUTY-INVOLVED>

</INVOICE-ITEMS>

<INVOICE-ITEMS>

<CETSH-NUMBER>84369100</CETSH-NUMBER>

<QUANTITY-CODE>KG</QUANTITY-CODE>

<QUANTITY>3368.00</QUANTITY>

<AMOUNT-OF-DUTY-INVOLVED>99653.00</AMOUNT-OF-DUTY-INVOLVED>

</INVOICE-ITEMS>

</INVOICE-PARTICULARS>

<INVOICE-PARTICULARS SL-NO="2">

<INVOICE-NUMBER>12556523655542154445</INVOICE-NUMBER>

<INVOICE-DATE>11/10/2009</INVOICE-DATE>

<INVOICE-ITEMS>

<CETSH-NUMBER>63064900</CETSH-NUMBER>

<QUANTITY-CODE>U</QUANTITY-CODE>

<QUANTITY>456.00</QUANTITY>

<AMOUNT-OF-DUTY-INVOLVED>2236.00</AMOUNT-OF-DUTY-INVOLVED>

</INVOICE-ITEMS>

</INVOICE-PARTICULARS>

</INVOICE-HEADER>

</ACES>

In the above Sample <INVOICE-ITEMS> child element came two times for the parent elemnt <INVOICE-PARTICULARS>. It is possible ?.

How to pass attribute values ?.

Pls help me to do.

Thanks in Advance.

2 REPLIES 2

Former Member
0 Kudos

Hi,

Just check this code for conversion of single string to xml format, change the code for internal table

data ixml type ref to if_ixml.

data streamFactory type ref to IF_IXML_STREAM_FACTORY.

data iStream type ref to if_ixml_istream.

data ixmlParser type ref to if_ixml_parser.

data xmlDoc type ref to if_ixml_document.

ixml = cl_ixml=>create( ).

xmlDoc = ixml->create_document( ).

streamFactory = ixml->CREATE_STREAM_FACTORY( ).

iStream = streamFactory->CREATE_ISTREAM_STRING( xmlString ).

iXMLParser = iXML->create_parser( stream_factory = streamFactory

istream = iStream

document = xmlDoc ).

iXMLParser->parse( ).

ixmlDocument = xmlDoc.

Regards,

Selva

GauthamV
Active Contributor
0 Kudos

Please SEARCH in SCN before posting, you have lot of posts available on

converting internal table to xml and vice versa.

You can also search using FM SAP_CONVERT_TO_XML_FORMAT.