2015 Jun 24 4:50 PM
When I run the program below and then open the resulting Excel file, I have two problems:
TYPES: xmlline(1024) TYPE x.
DATA: lt_t005 TYPE STANDARD TABLE OF t005.
DATA: lt_xml TYPE STANDARD TABLE OF xmlline.
SELECT * FROM t005 INTO TABLE lt_t005 UP TO 100 ROWS.
CALL TRANSFORMATION id
SOURCE data_node = lt_t005
RESULT XML lt_xml.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'C:\Users\Mike\Desktop\test.xls'
filetype = 'BIN'
CHANGING
data_tab = lt_xml.
Thanks,
Mike
2015 Jun 24 5:12 PM
Hi.
As for first point, you MANDT is part of T005 table so it will be send by transformation ID always, a workaround is to have a type with all the fields of T005 exluding the MANDT one and use it as the table type for the internal table LT_T005, the do the select query as usual.
Regards.
When I run the program below and then open the resulting Excel file, I have two problems:
TYPES: xmlline(1024) TYPE x.
DATA: lt_t005 TYPE STANDARD TABLE OF t005.
DATA: lt_xml TYPE STANDARD TABLE OF xmlline.
SELECT * FROM t005 INTO TABLE lt_t005 UP TO 100 ROWS.
CALL TRANSFORMATION id
SOURCE data_node = lt_t005
RESULT XML lt_xml.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'C:\Users\Mike\Desktop\test.xls'
filetype = 'BIN'
CHANGING
data_tab = lt_xml.
Thanks,
Mike
2015 Jun 24 5:12 PM
Hi.
As for first point, you MANDT is part of T005 table so it will be send by transformation ID always, a workaround is to have a type with all the fields of T005 exluding the MANDT one and use it as the table type for the internal table LT_T005, the do the select query as usual.
Regards.
2015 Jun 25 1:20 PM
Yes, I understand that about MANDT. That field clearly should be the first field listed. But for some reason this new VERSION field, generated from version = 1.0 tag in the XML (I guess), is coming up first. The VERSION field is the one I need to get rid of.
Mike
2015 Jun 25 3:55 PM
This is how the generated XML looks. This highlighted version is treated "common" by excel XML table and would be thus present to all the columns.
<?xml version="1.0" encoding="utf-16"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DATA_NODE>
<T005>
<MANDT>100</MANDT>
<LAND1>AD</LAND1>
...
</T005>
</DATA_NODE>
</asx:values>
<asx:abap>
Either you can get the XML response into XML object (IF_IXML_DOCUMENT) or get into the string and replace the node.
Or you can create your own little transformation and omit this version.
Regards,
Naimesh Patel
2015 Jun 26 2:04 PM
Perfect. Thanks Naimesh, that works. In case anyone comes along with the same problem later, using what Naimesh told me I:
And it worked perfectly - No Version column in my resulting Excel file.
2015 Jun 26 2:48 PM
I simplified your approach by receiving the XML result in the string, instead of the xstring. So, no need to convert from xstring to string for manipulation. Also used the method EXPORT_TO_FILE of class CL_XML_DOCUMENT.
DATA: lt_t005 TYPE STANDARD TABLE OF t005.
DATA: lv_xml TYPE string.
DATA: lo_xml_doc TYPE REF TO cl_xml_document.
SELECT * FROM t005 INTO TABLE lt_t005 UP TO 100 ROWS.
CALL TRANSFORMATION id
SOURCE data_node = lt_t005
RESULT XML lv_xml.
REPLACE FIRST OCCURRENCE OF
'<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'
IN lv_xml
WITH '<asx:abap xmlns:asx="http://www.sap.com/abapxml">'.
CREATE OBJECT lo_xml_doc.
lo_xml_doc->parse_string( lv_xml ).
lo_xml_doc->export_to_file( 'c:\temp\t005_new_1.xls' ).
Regards,
Naimesh Patel