cancel
Showing results for 
Search instead for 
Did you mean: 

Download Internal Table to Excel via Web Dynpro

Former Member
0 Kudos

Hi All,

A requirement is to download the contents of internal table to excel.

CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'

IMPORTING

text = l_text

TABLES

text_tab = lt_tab.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = l_text

IMPORTING

buffer = lv_xstring_data

EXCEPTIONS

failed = 1

OTHERS = 2.

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

EXPORTING

i_filename = 'Excel.xls'

i_content = lv_xstring_data

i_mime_type = 'EXCEL'.

The problem is the internal table contains a field with numeric value. Say my internal table has a value of 1.00, when this is downloaded, the values is becoming 1. The decimal fields are removed.

Any idea on how this should be handled?

Thanks,

Louisse

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

Hi All,

>

> A requirement is to download the contents of internal table to excel.

>

> CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'

> IMPORTING

> text = l_text

> TABLES

> text_tab = lt_tab.

>

> CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

> EXPORTING

> text = l_text

> IMPORTING

> buffer = lv_xstring_data

> EXCEPTIONS

> failed = 1

> OTHERS = 2.

>

> CALL METHOD cl_wd_runtime_services=>attach_file_to_response

> EXPORTING

> i_filename = 'Excel.xls'

> i_content = lv_xstring_data

> i_mime_type = 'EXCEL'.

>

Hi,

have you concatenate l_text with the contents. ,like .,

loop at LT_SFLIGHT into LS_SFLIGHT.
    concatenate l_text  LS_SFLIGHT-CARRID
                LS_SFLIGHT-CONNID
                LS_SFLIGHT-FLDATE
                LS_SFLIGHT-CURRENCY
                LS_SFLIGHT-PLANETYPE
                CL_ABAP_CHAR_UTILITIES=>NEWLINE into l_text separated by
                CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
  endloop.

After this now pass l_text to FM SCMS_STRING_TO_XSTRING .

hope this helps you.

Thanks & Regards,

Kiran

madhu_vadlamani
Active Contributor
0 Kudos

Hi Louisse,

Check there are some good points was posted by micahel in the wiki.

[Download Into Excel|http://wiki.sdn.sap.com/wiki/display/ABAP/ExportingdatatoExcel-XMLtotherescue]

Regards,

Madhu.