Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Download data

Former Member
0 Likes
908

Hello friends,

I have downloaded data from Internal table to text file. But my requirement wants it to download in excel sheet.

are there any FM that download data in excel sheet.

Shejal.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
861

Hi Shejal,

You can use FM GUI_DOWNLOAD.

data: it001 type table of t001 with header line. 

select * into table it001 from t001. 
call function 'GUI_DOWNLOAD'     
  exporting          
    filename              = 'C:test.xls'
    write_field_separator = 'X'     
  tables          
    data_tab              = it001.

Regards,

Ferry Lianto

Hello friends,

I have downloaded data from Internal table to text file. But my requirement wants it to download in excel sheet.

are there any FM that download data in excel sheet.

Shejal.

6 REPLIES 6
Read only

Former Member
0 Likes
861

Hi shejal,

1. This text file can be opened in excel.

regards,

amit m.

Read only

Former Member
0 Likes
861

Shejal,

try 'EXCEL_OLE_STANDARD_DAT'.

-Anu.

Read only

Former Member
0 Likes
861

hi Shejal,

data lv_file name type string.

data download1 type table (your internal table)

call function 'GUI_FILE_SAVE_DIALOG'

EXPORTING

WINDOW_TITLE = 'Enter File Name'

DEFAULT_EXTENSION = 'XLS'

DEFAULT_FILE_NAME = 'shejal.xls'

IMPORTING

FULLPATH = lv_filename.

call function 'GUI_DOWNLOAD'

exporting

filename = lv_filename

FILETYPE = 'DAT'

tables

data_tab = download1.

This code will download the file in tab delimited form..but will be open with excel...

you can change the delimeter option...by including the file_separator export parameter to gui

_download functin module.

Hope this helps.

Sajan.

Read only

0 Likes
861

Thanks for all the suggestions,

right now i am downloading the file in tab delimited and opening it in EXCEL.

But the business people dont want to do this. They want it to be downloaded in excel itself.

there anr many files that will be created every hour, so dont want to convert the text file to excel manually.

However I am having one more problem in text file.

Eg- suppose I am downloading two fields,

Kunnr and matnr

when I download they dont want any leading zeros.

so I am having problem with alingment for different rows if the number of char are different,

my output file looks like this.

12345 5632

1234567 5234

125 854889

So I am having problems cnverting into excel.

any suggestions,

Shejal.

Read only

Former Member
0 Likes
861

Hi Shejal,

Try this:

A simple option:

a) form download_file .

call function <b>'WS_EXCEL'</b>

importing

filename = excel_name

tables

data = itab.

b) call function <b>'WS_DOWNLOAD'</b>

exporting

filename = o_file

filetype = 'DAT'

tables

data_tab = i_tab

exceptions

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

others = 11.

if sy-subrc = 0.

message 'File is downloaded successfully' type 'I'.

endif.

CALL FUNCTION <b>'SAP_CONVERT_TO_XLS_FORMAT'</b>

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

i_filename =

  • I_APPL_KEEP = ' '

tables

i_tab_sap_data =

  • CHANGING

  • I_TAB_CONVERTED_DATA =

  • EXCEPTIONS

  • CONVERSION_FAILED = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Another FM –

<b>MS_EXCEL_OLE_STANDARD_DAT</b>

Reward points if this helps.

Manish

Message was edited by: Manish Kumar

Read only

Former Member
0 Likes
862

Hi Shejal,

You can use FM GUI_DOWNLOAD.

data: it001 type table of t001 with header line. 

select * into table it001 from t001. 
call function 'GUI_DOWNLOAD'     
  exporting          
    filename              = 'C:test.xls'
    write_field_separator = 'X'     
  tables          
    data_tab              = it001.

Regards,

Ferry Lianto