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

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

Former Member
0 Likes
1,519

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

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

3 REPLIES 3
Read only

athavanraja
Active Contributor
0 Likes
1,290

Hi,

<i><b>open dataset lv_xml_file for output in binary mode.</b></i>

did you try using the "TEXT" mode?

Regards

Raja

Read only

0 Likes
1,290

Hi Raja,

tried the "TEXT" mode, but that didn't help.

There are still characters after the last tag, that are not supposed to be there including a date that is not

the creation date of the file.

Thank you for your help.

Regards

Johannes

Read only

Former Member
0 Likes
1,290

Hi,

Did you ever get this resolved. I am enouctering the same issue now.

Please help if you can.

Thanks many.