Professional Documents
Culture Documents
com/2015/08/call-transformation-to-download-excel/
ZEVOLVING
“
TOP
Code snippet to show the usage of the ABAP Call Transformation to transform the data easily into the excel format by XML and download it.
*
SELECT *
FROM t100
INTO TABLE t_t100
UP TO 100 ROWS
WHERE SPRSL EQ sy-langu.
*
CALL TRANSFORMATION ID
SOURCE data_node = t_t100
RESULT XML lv_xml.
*
CREATE OBJECT lo_xml_doc.
lo_xml_doc->parse_string( lv_xml ).
lo_xml_doc->export_to_file( 'c:tempt100.xls' ).
TOP
zevolving.com is founded by and maintained by Naimesh Patel. You can help by submitting your articles via Write a Post. The site is built on Wordpress.
Happy Designing!
All product names are trademarks of their respective companies. zevolving.com is not affiliated with SAP AG.
File as XML
*
SELECT *
FROM t100
INTO TABLE t_t100
UP TO 100 ROWS
WHERE SPRSL EQ sy-langu.
*
CALL TRANSFORMATION ID
SOURCE data_node = t_t100
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:tempt100.xls' ).
Do you have a Code Snippet which you want to share, Submit Code Snippet here
Tags
7 Comments
Rudolf Leye
# August 4th, 2015 at 7:32 am
I don’t really like a processed XML object being serialized to string, worked over with text processing and being de-serialized back again
to remove an XML attribute…
Why not use the methods the way they are designed to be used:
Naimesh Patel
# August 4th, 2015 at 9:26 am
Hello Rudolf,
I think I had tried to set the version by using the method SET_VERSION, but it sets the version of the XML document to blank, not the
version within the asx:abap node.
?xml version=””?
Due to this, the document wont open in excel.
I even tried to parse the nodes from XML and tried to use the SET_VERSION column, but it actually leaves the VERSION tag as is but
only replaces the value. Hence used the STRING and REplace.
Thanks, TOP
Naimesh Patel
Mohit
# August 10th, 2015 at 7:32 am
Hi Naimesh,
Regards
Mohit
Naimesh Patel
# August 10th, 2015 at 10:51 am
Hello Mohit,
I think using this ID transformation, it is not possible to change the column names. ID transformation is the identity transformation which
is used for copying the source documents to target and vice versa. So, there is no space for any change.
Thanks,
Naimesh Patel
Siddharth
# August 15th, 2015 at 2:40 pm
Hi Naimesh,
Rudolf Leye
# August 24th, 2015 at 6:39 am
Then you can generate a valid xml tha fulfils the specification given.
Raju Shrestha
# September 15th, 2015 at 9:13 am
As Rudolf said, we are playing processed XML. But when no other ways look helpful, this trick does the work..
Regards,
Raju.
Comments on this Post are now closed. If you have something important to share, you can always contact me.
TOP