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

Convert Internal Table to XML File

former_member188001
Active Participant
0 Likes
957

All,

I have a requirement where, an internal table needs to be converted to XML file. I know the output format required for the file, but not sure how the internal table should be defined for that or how to populate the internal table. Also, would like to know how do I then convert the internal table to the XML file.

Following is the sample of the file required.

<STATE>DC

<COUNTY>ADAMS MORGAN

<NEIGHBORHOOD>NW

<ADDRESS>1100, 15TH STREET</ADDRESS>

<ADDRESS>1100, 16TH STREET</ADDRESS>

<ADDRESS>1100, 17TH STREET</ADDRESS>

<ADDRESS>1100, 18TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>NE

<ADDRESS>100, 1ST STREET</ADDRESS>

<ADDRESS>100, 2ND STREET</ADDRESS>

<ADDRESS>100, 3RD STREET</ADDRESS>

<ADDRESS>100, 4TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

<COUNTY>MONTGOMERY

<NEIGHBORHOOD>SW

<ADDRESS>1100, 15TH STREET</ADDRESS>

<ADDRESS>1100, 16TH STREET</ADDRESS>

<ADDRESS>1100, 17TH STREET</ADDRESS>

<ADDRESS>1100, 18TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>SE

<ADDRESS>100, 1ST STREET</ADDRESS>

<ADDRESS>100, 2ND STREET</ADDRESS>

<ADDRESS>100, 3RD STREET</ADDRESS>

<ADDRESS>100, 4TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

</STATE>

<STATE>VA

<COUNTY>ARLINGTON

<NEIGHBORHOOD>BALLSTON

<ADDRESS>900 NORTH STUART STREET</ADDRESS>

<ADDRESS>4001 N 9TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>COURT HOUSE

<ADDRESS>9 NORTH STREET</ADDRESS>

<ADDRESS>40TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

<COUNTY>RICHMOND

<NEIGHBORHOOD>TOMS RIVER

<ADDRESS>900 NORTH STUART STREET</ADDRESS>

<ADDRESS>4001 N 9TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

</STATE>

Any help on this will be greatly appreciated.

Regards,

Salil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
829

Hi Salil,

Please refer to [Convert an ABAP table into XML file using SAP DOM Approach.|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2657] [original link is broken] [original link is broken] [original link is broken];.

Hope this helps.

All,

I have a requirement where, an internal table needs to be converted to XML file. I know the output format required for the file, but not sure how the internal table should be defined for that or how to populate the internal table. Also, would like to know how do I then convert the internal table to the XML file.

Following is the sample of the file required.

<STATE>DC

<COUNTY>ADAMS MORGAN

<NEIGHBORHOOD>NW

<ADDRESS>1100, 15TH STREET</ADDRESS>

<ADDRESS>1100, 16TH STREET</ADDRESS>

<ADDRESS>1100, 17TH STREET</ADDRESS>

<ADDRESS>1100, 18TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>NE

<ADDRESS>100, 1ST STREET</ADDRESS>

<ADDRESS>100, 2ND STREET</ADDRESS>

<ADDRESS>100, 3RD STREET</ADDRESS>

<ADDRESS>100, 4TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

<COUNTY>MONTGOMERY

<NEIGHBORHOOD>SW

<ADDRESS>1100, 15TH STREET</ADDRESS>

<ADDRESS>1100, 16TH STREET</ADDRESS>

<ADDRESS>1100, 17TH STREET</ADDRESS>

<ADDRESS>1100, 18TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>SE

<ADDRESS>100, 1ST STREET</ADDRESS>

<ADDRESS>100, 2ND STREET</ADDRESS>

<ADDRESS>100, 3RD STREET</ADDRESS>

<ADDRESS>100, 4TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

</STATE>

<STATE>VA

<COUNTY>ARLINGTON

<NEIGHBORHOOD>BALLSTON

<ADDRESS>900 NORTH STUART STREET</ADDRESS>

<ADDRESS>4001 N 9TH STREET</ADDRESS>

</NEIGHBORHOOD>

<NEIGHBORHOOD>COURT HOUSE

<ADDRESS>9 NORTH STREET</ADDRESS>

<ADDRESS>40TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

<COUNTY>RICHMOND

<NEIGHBORHOOD>TOMS RIVER

<ADDRESS>900 NORTH STUART STREET</ADDRESS>

<ADDRESS>4001 N 9TH STREET</ADDRESS>

</NEIGHBORHOOD>

</COUNTY>

</STATE>

Any help on this will be greatly appreciated.

Regards,

Salil

5 REPLIES 5
Read only

Former Member
0 Likes
830

Hi Salil,

Please refer to [Convert an ABAP table into XML file using SAP DOM Approach.|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2657] [original link is broken] [original link is broken] [original link is broken];.

Hope this helps.

Read only

alex_cook
Active Participant
0 Likes
829

Howdy,

You should consider using a Simple Transformation - they are fairly easy to pick up and can be used to convert from XML to internal table and vice versa.

Here's a link to the SAP help:

http://help.sap.com/saphelp_nw04s/helpdata/EN/e3/7d4719ca581441b6841f1054ff1326/frameset.htm

and a link to the wiki page with examples

http://wiki.sdn.sap.com/wiki/display/ABAP/Transformations

Cheers

Alex

Read only

mvoros
Active Contributor
0 Likes
829

Hi,

you can use dump approach and generate XML manually with help of CONCATENATE. XSLT is better option and DOM might be too slow.

Cheers

Read only

former_member188001
Active Participant
0 Likes
829

Thanks everyone for your responses. I am now able to convert internal table into XML with hierarchies.

Read only

Former Member
0 Likes
829

This message was moderated.