Application Development 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: 

internal table to xml-file using simple transformation

Former Member
0 Kudos

Hi there!

I need to save an internal table as xml-file on desktop.

I tried to do this by using call transformation. I wrote the transformation as following below.

But unfortunately, when I test my programm, I get a runtime error and the error message:

"The goal was to access the variable "ROOT".However,this access was not possible."

Exception was triggered in line:

Hope to hear/read from you soon!

Johann

Message was edited by:

Johann Just

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Johann,

Use the function module <b>SAP_CONVERT_TO_XLS_FORMAT</b> to download the internal table to an excel file

Look at this example:

PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:\tmp\test.xls'.

DATA: t100_Lines TYPE STANDARD TABLE OF t001 WITH DEFAULT KEY.

SELECT * FROM t001 INTO TABLE t100_Lines.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

i_filename = p_file

TABLES

i_tab_sap_data = t100_Lines.

Reward Points.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Go through the links,

Regards,

Azaz Ali.

0 Kudos

Hi Azaz!

thanks for answering so quickly, unfortunately the threads you referred to are not really helping, because i do not have any problems with saving the xml-file, but the transformation which is called by CALL TRANSACTION is not working(see code of transformation above).

Can you explain to me why?

I insert the program which should use the ST here for better understanding....

&----


*& Report Z_CONVERT_TO_XML

*&

&----


*&

*&

&----


REPORT z_convert_to_xml.

DATA: xml_out TYPE string .

DATA : wa_itab TYPE STANDARD TABLE OF zuploadtxt

WITH HEADER LINE.

DATA: l_xml_table TYPE TABLE OF zuploadtxt.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\MELD_ZRST.txt'

filetype = 'ASC'

has_field_separator = 'X'

replacement = '#'

TABLES

data_tab = wa_itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL TRANSFORMATION zz_joerns

SOURCE root = wa_itab

RESULT XML xml_out.

APPEND xml_out TO l_xml_table.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = 'c:\temp\XMLTRY.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Former Member
0 Kudos

Hi Johann,

Use the function module <b>SAP_CONVERT_TO_XLS_FORMAT</b> to download the internal table to an excel file

Look at this example:

PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:\tmp\test.xls'.

DATA: t100_Lines TYPE STANDARD TABLE OF t001 WITH DEFAULT KEY.

SELECT * FROM t001 INTO TABLE t100_Lines.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

i_filename = p_file

TABLES

i_tab_sap_data = t100_Lines.

Reward Points.

0 Kudos

Hi!

I donot have a problem saving the internal table as a xml-file, can be done easily using the CL_XML_DOCUMENT class. But I want to learn more about simple transformations...

Anyhow, thanks

0 Kudos

check out this excellent weblog series on ST

/people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1

/people/tobias.trapp/blog/2005/05/17/xml-processing-in-abap-part-2

/people/tobias.trapp/blog/2005/05/20/xml-processing-in-abap-part-3

/people/tobias.trapp/blog/2005/05/27/xml-processing-in-abap-part-4

/people/tobias.trapp/blog/2005/06/15/xml-processing-in-abap--part-5

/people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6

Raja

Former Member
0 Kudos

did it myself