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 to XML format

Former Member
0 Likes
5,464

Hi Everyone,

I am working on some Interface where I need to convert the data avilable in internal table to XML format, can anyone please tell me how this can be achieved.

Rgds,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,903

Hi,

That largely depends on the app server version you're working with.

As of version 6.10 there is a built-in xml engine which you can make use of e. g. with the new ABAP command CALL TRANSFORMATION (just see the online help if applicable).

Before that you would have to build up the XML data "by hand", using the objects in package SIXML. If the latter is the case for you, have a look at the sample programs in package SIXML_TEST.

Hope that helps (plz reward me if it does ,

Joerg

12 REPLIES 12
Read only

Former Member
0 Likes
2,904

Hi,

That largely depends on the app server version you're working with.

As of version 6.10 there is a built-in xml engine which you can make use of e. g. with the new ABAP command CALL TRANSFORMATION (just see the online help if applicable).

Before that you would have to build up the XML data "by hand", using the objects in package SIXML. If the latter is the case for you, have a look at the sample programs in package SIXML_TEST.

Hope that helps (plz reward me if it does ,

Joerg

Read only

0 Likes
2,903

Hi Joerg,

Thaks for the useful suggestions, they were really useful. I found some function modules which can convert the data in XML format, but I am really not sure whether they are the right ones to use. Can you please let me know if there are any ready made reports available to do the conversion.

Thanks in Advance.

Read only

0 Likes
2,903

Hi Lalitha,

Just look at this piece of code, I think it should help you.

  DATA : ITAB   TYPE TABLE OF SPFLI,
         L_XML  TYPE REF TO CL_XML_DOCUMENT.

  SELECT * FROM SPFLI INTO TABLE ITAB.

* CREATE THE XML OBJECT
  CREATE OBJECT L_XML.

* CONVERT THE DATA TO XML
  CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB[] ).

* DATA IS CONVERTED TO XML; DISPLAY THE XML-DOCUMENT
  CALL METHOD L_XML->DISPLAY.

Regards,

Anand Mandalika.

Read only

0 Likes
2,903

Hi,

You can also use the folloing two function modules to convert the data in an internal table to XML format.

Step 1: Convert to Data Object Model using

'SDIXML_DATA_TO_DOM'

Step 2: Conver to XML using

'SDIXML_DOM_TO_XML'

Good luck,

Suresh Datti

Read only

0 Likes
2,903

Hi Anand,

Thank you very much for the timely help, the code sent by you was very useful and I incorporated the same in my program.

Rgds,

Read only

0 Likes
2,903

Hello Lalitha,

If your problem is resolved, then could you please close this thread ? You do that either by

1. rewarding 10 points to the answer that has solved your problem.

or by

2. choosing the option "Solved it on my own".

That would help the guys out there trying to answer the queries. they would know that this question has been resolved.

Regards,

Anand Mandalika.

Read only

0 Likes
2,903

Hi ,

I am using the function modules :

Step 1: Convert to Data Object Model using

'SDIXML_DATA_TO_DOM'

Step 2: Conver to XML using

'SDIXML_DOM_TO_XML'

They work fine in a normal report. But when I use them in a method in a business object, they behave strangely.

The XML structure generated ignoring the fields with blank values. I want the entire structure to be aded in the XML file including the blank fields.

This happens for a report program , but does not happen for a method of a bisuness object.

May I doing something wrong?

Rgds,

Namita.

Read only

0 Likes
2,903

Hi Anand,

Your code is very useful to my program, but I have a question,

CALL METHOD L_XML->DISPLAY. >>>> instead of display can I write it to a file on app.server.

Thanks

Read only

Former Member
0 Likes
2,903

Hello. I have a question relating to this topic. I am on R/3 v46B. Is there any FM that can convert an ABAP internal table to XML ?

Read only

0 Likes
2,903

Hello Joyce,

I am able to find the class CL_XML_DOCUMENT in 4.6C also. Unfortunately, I don't have any 4.6B system. Could you check out the aboove code in 4.6B if the class exists?

But if you're particular about using a Function Module, then you should have a look at the FM SAP_CONVERT_TO_XML_FORMAT, if it is available in your system.

Regards,

Anand Mandalika.

Read only

christianpunz
Participant
0 Likes
2,903

be careful, in 4.6C the fm SAP_CONVERT_TO_XML_FORMAT has problems with big amounts of data (had 73000 records of 220 byte length). the program consumed tons of memory during the fm SAP_CONVERT... (>500 MB seen in SM50) and never came back...

the solution mentioned by Poornanand Mandalika performed far better!

kind regards

christian punz

Read only

0 Likes
2,903

Hello poornandh,

Can u tel me how to download the converted xml file data according to CALL METHOD L_XML->DISPLAY.


I have different  format of XML File which i am unable to  generate by these methods suggested by u.


Please help me as early as possible.