cancel
Showing results for 
Search instead for 
Did you mean: 

pbm with downloading internal table to excel

Former Member
0 Kudos

Hi Experts ,

I have to download an internal table to an excel sheet. I have tried the code given below.

But this is not giving me desired output in excel.

method ATTACH_FILES .

*data:

  • conv_out type ref to cl_abap_conv_out_ce,

  • content type xstring.

*

*

*

*

  • conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

*

data : itab_sflight type table of sflight.

data: xml_out TYPE string.

data: conv_out type ref to cl_abap_conv_out_ce.

data: content1 type xstring.

import itab_sflight1 to itab_sflight from MEMORY ID 'ZCA'.

call transformation ('ID') source tab = itab_sflight result xml xml_out.

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = xml_out

  • MIMETYPE = ' '

  • ENCODING =

IMPORTING

BUFFER = content1

  • EXCEPTIONS

  • FAILED = 1

  • OTHERS = 2

.

  • attach the first file

conv_out->convert( exporting data = content1 ).

cl_wd_runtime_services=>attach_file_to_response(

i_filename = 'file1.XLS'

i_content = content1

i_mime_type = 'application/msexcel'

i_in_new_window = i_in_new_window

i_inplace = i_inplace ).

endmethod.

The output in excel is coming in Xml format.

like <carrid>lh<\carrid><seatno>value<\seatno> and so on

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello shaheen,

yups i have same problem here.See if you try to open up your XML output

in MS- Excel 2003 version (11.8117.8107 OR later ) SP2 you will face problem beacuse excel will not ask you for wherther you want to open file as "XML LIST".But my colleague in diffrent country they have version 2003 (11.5612.5606)

you can see its not the latest whenever they open downloaded file,excel ask them to open in "XML LIST" and output is perfect.So i guess its problem with EXCEL.

NIRAD

Former Member
0 Kudos

Hi Nirad,

I dont know in what version will the client work on.

So is it not possible to get the output irrespective of the version of the excel?

Also i have a 2002 version SP3 excel and it doesnt show me the output .

It says the file cant be opened because:

Invalid at the top level of the document.

Kindly update me if you get to know more about this.

Regards,

Shaheen

Former Member
0 Kudos

See we swtched to ALV and ALV gives us perfect output in EXCEL.You install office 2003 and check it out or try to open that as XML lsit...or there is a XML reader add on available in excel so install that add on and check can u do it or not.

Nirad