Skip to Content
0
Apr 02, 2013 at 12:59 PM

Download to excel file has a blank column

590 Views

Dear Experts,

I used the below mentioned code to download data from table. I am able to succesfully download the data but the first column is coming as blank. It will be helpful if i get help to remove the blank column from the excel sheet.

DATA: str TYPE string,
str1 TYPE string,
xstr TYPE xstring.

LOOP AT lt_ekko INTO ls_ekko .

IF str = ' ' .
CONCATENATE 'Ebeln'
'BUKRS'
'BSTYP'
'BSART'
cl_abap_char_utilities=>newline INTO str SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.

else.
CONCATENATE str
ls_ekko-EBELN
ls_ekko-BUKRS
ls_ekko-BSTYP
ls_ekko-BSART
cl_abap_char_utilities=>newline INTO str SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.

endif.

ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = str
IMPORTING
buffer = xstr
EXCEPTIONS
failed = 1.
"Attach file
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'Download.xls'
i_content = xstr
i_mime_type = 'EXCEL'
i_in_new_window = abap_false
i_inplace = abap_false.

Thanks & Regards

Arun.K.P