Skip to Content
author's profile photo Former Member
Former Member

Export Internal Table to XML in Background

Hi

I need to export a internal table into xml file in background using open dataset. The file is getting created but i am not able to open the file using IE/XML editor . When i open the file uisng wordpad i can see some charcters at the end of file which prevents it from opening in xml editor. if i delete the characters(box like) and save the file. i am able to open the file

When i downalod the same internal table via frontend using ws_downlod it works pefectly. no junk charcters are appended in the end. and hence files opens perfectly

below is the extract of program

START-OF-SELECTION.

PERFORM get_data.

PERFORM create_xml.

FORM get_data.

REFRESH accesos.

CLEAR accesos.

MOVE: '45050' TO accesos-socio-numero,

'MOISES MORENO' TO accesos-socio-nombre,

'0' TO accesos-socio-reposicion.

APPEND accesos.

ENDFORM.

i am using the following function modules

CALL FUNCTION 'SDIXML_DATA_TO_DOM'

EXPORTING

name = 'ACCESOS'

dataobject = accesos[]

IMPORTING

data_as_dom = l_dom

CHANGING

document = m_document

EXCEPTIONS

illegal_name = 1

OTHERS = 2.

CHECK NOT l_dom IS INITIAL.

w_rc = m_document->append_child( new_child = l_dom ).

CALL FUNCTION 'SDIXML_DOM_TO_XML'

EXPORTING

document = m_document

IMPORTING

xml_as_string = w_string

size = w_size

TABLES

xml_as_table = it_xml

EXCEPTIONS

no_document = 1

OTHERS = 2.

LOOP AT it_xml INTO xml_tab-d.

APPEND xml_tab.

ENDLOOP.

The following syntax for open datset which does not work

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

lv_physcial_file = '
hdat03\test.xml'.

OPEN DATASET lv_physcial_file IN BINARY MODE FOR OUTPUT MESSAGE l_msg.

LOOP AT xml_tab.

TRANSFER xml_tab TO lv_physcial_file.

ENDLOOP.

The ws_download function works

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

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

BIN_FILESIZE = W_SIZE

FILENAME = GK_RUTA

FILETYPE = 'BIN'

TABLES

DATA_TAB = XML_TAB

EXCEPTIONS

OTHERS = 10.

many thnaks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2009 at 07:19 PM

    Hi Chetan,

    Can you just try changing the syntax to the following, I not sure if that will help but just try and see.

    OPEN DATASET lv_physcial_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    Regards

    Mohamed

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 14, 2009 at 09:51 PM

    could you tell us what is data type of xml_tab

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.