Skip to Content
0
Former Member
Nov 02, 2004 at 03:02 PM

Create XML file on application server (unix directory) from internal table

189 Views

Hallo everybody,

I have got the following problem:

I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.

This takes place in 3 steps:

1. Collect the data in an internal table

2. Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'

3. Download the data

If I download the converted data, which are in an internal table, to the presentation server via the function module ‘WS_DOWNLOAD’ and open it with the Internet Explorer, everything is ok.

If I download the converted data to the application server, i.e. into a unix directory via

‘open dataset’, ‘loop at internal table, ‘transfer working area to file’, ‘close dataset’

and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that aren’t supposed to be there. That’s what my colleagues told me, for I haven’t got access to the server.

I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately I’I am not an expert in working with classes so sample coding would have to be rather detailed.

Here’s some more information about how I work with the conversion function module:

call function 'SAP_CONVERT_TO_XML_FORMAT'

exporting

i_field_seperator = lv_field_seperator

  • i_line_header = lv_line_header

  • i_filename = lv_xml_file

  • i_appl_keep = ' '

i_xml_doc_name = lv_xml_doc_name

importing

pe_bin_filesize = lv_result

tables

i_tab_sap_data = gt_data

changing

i_tab_converted_data = lt_tab_converted_data

exceptions

conversion_failed = 1

others = 2.

lv_field_seperator = ‘X’.

lv_xml_doc_name = ‘Personalstammdaten Publikation’

lv_result: type i

gt_data: fields: PERNR, PERSG, PERSK etc.

types:

begin of truxs_xml_line,

data(256) type x,

end of truxs_xml_line.

types:

truxs_xml_table type table of truxs_xml_line.

data:

lv_tab_converted_data type truxs_xml_line,

lt_tab_converted_data type truxs_xml_table

open dataset lv_xml_file for output in binary mode.

loop at lt_tab_converted_data into lv_tab_converted_data.

transfer lv_tab_converted_data to lv_xml_file.

endloop.

close dataset lv_xml_file

lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml

Hope the information is detailed enough! Otherwise let me know. Thank you in advance.

Message was edited by: Johannes Schwehm