Application Development 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: 

Internal table to excel on presentation server

Former Member
0 Kudos

Hi All,

Is there a function module other than GUI_DOWNLOAD which downloads a internal table to xls format i,e it is required to have each of the fields of the internal table to go into the corresponding cells of xls..

or is it possible to achieve this using GUI_DOWNLOAD.

TIA,

Sharat.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

use GUI_DOWNLOAD FM

data : filename type string,

fl_type type char10 value 'ASC'.

FILENAME ' 'C:\TEST.xls'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = FILENAME

FILETYPE = 'ASC'

  • APPEND = ' '

<b>WRITE_FIELD_SEPARATOR = ','</b>

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

<b>u also use that.....

'SAP_CONVERT_TO_XLS_FORMAT'</b>REPORT Zxls .

parameters: p_file like rlgrap-filename default 'c:\temp\test01.xls'.

data: itab like t001 occurs 0 with header line.

CLEAR itab.

REFRESH itab.

select * from t001 into table itab.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

I_FILENAME = p_file

TABLES

I_TAB_SAP_DATA = itab

9 REPLIES 9

Former Member
0 Kudos

use GUI_DOWNLOAD FM

data : filename type string,

fl_type type char10 value 'ASC'.

FILENAME ' 'C:\TEST.xls'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = FILENAME

FILETYPE = 'ASC'

  • APPEND = ' '

<b>WRITE_FIELD_SEPARATOR = ','</b>

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

<b>u also use that.....

'SAP_CONVERT_TO_XLS_FORMAT'</b>REPORT Zxls .

parameters: p_file like rlgrap-filename default 'c:\temp\test01.xls'.

data: itab like t001 occurs 0 with header line.

CLEAR itab.

REFRESH itab.

select * from t001 into table itab.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

I_FILENAME = p_file

TABLES

I_TAB_SAP_DATA = itab

Former Member
0 Kudos

yes its possible in GUI_DOWNLOAD,

make FILETYPE = 'ASC'

<b> to FILETYPE = 'DAT'</b>

Former Member
0 Kudos

See if these blogs will be helpful

/people/sap.user72/blog/2006/02/07/downloading-data-into-excel-with-format-options

/people/sergio.ferrari2/blog/2006/06/12/spreadsheet-integration--which-approach-for-which-sap-technology

Regards,

Ravi

Note : Please mark all the helpful answers

Former Member
0 Kudos

Here is a sample program.

report ztest_0001.

data:

file type string,

path type string,

file_path type string,

return type i..

data: itab type table of string.

data: wa type string.

start-of-selection.

wa = 'This is row1'. append wa to itab.

wa = 'This is row2'. append wa to itab.

call method cl_gui_frontend_services=>file_save_dialog

changing

filename = file

path = path

fullpath = file_path.

check not file_path is initial.

call method cl_gui_frontend_services=>gui_download

exporting

filename = file_Path

changing

data_tab = itab.

andreas_mann3
Active Contributor
0 Kudos

hi,

or use OLE -> compare demo-report <b>RSDEMO01</b>

and this pdf from <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">Serdar Simsekler</a>

Andreas

Former Member
0 Kudos

Yes you have lots of FMs available..

See the link for those with exmaples

rgds,

TM.

Former Member
0 Kudos

Hi,

Use any of the one,

cl_gui_frontend_services=>gui_download

(or)

GUI_DOWNLOAD

Regs,

Venkat Ramanan N

Former Member
0 Kudos

Hi Sharat,

U can use this FM : 'EXCEL_OLE_STANDARD_DAT'

DATA: BEGIN OF i_tab OCCURS 0,

anlage(20) TYPE c,

num(2) TYPE c,

END OF i_tab.

DATA: BEGIN OF i_head OCCURS 0,

field(30) TYPE c,

END OF i_head.

i_tab-anlage = '0070002545'.

i_tab-num = '1'.

APPEND i_tab.

CLEAR i_tab.

i_tab-anlage = '0070002546'.

i_tab-num = '2'.

APPEND i_tab.

CLEAR i_tab.

i_tab-anlage = '0070002547'.

i_tab-num = '3'.

APPEND i_tab.

CLEAR i_tab.

i_tab-anlage = '0070002548'.

i_tab-num = '4'.

APPEND i_tab.

CLEAR i_tab.

i_head-field = 'Installation'.

APPEND i_head.

i_head-field = 'NO'.

APPEND i_head.

CLEAR i_head.

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

file_name = 'C:\Documents and Settings\vepakom\Desktop\test1.xls'

create_pivot = 0

data_sheet_name = 'MY DATA'

  • PIVOT_SHEET_NAME = ' '

  • PASSWORD = ' '

  • PASSWORD_OPTION = 0

TABLES

pivot_field_tab = dlpivot

data_tab = i_tab

fieldnames = i_head

EXCEPTIONS

file_not_exist = 1

filename_expected = 2

communication_error = 3

ole_object_method_error = 4

ole_object_property_error = 5

invalid_pivot_fields = 6

download_problem = 7

OTHERS = 8

.

IF sy-subrc <> 0.

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

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

ENDIF.

Hope this will help u in some way.

Former Member
0 Kudos

CALL FUNCTION <b>'EXCEL_OLE_STANDARD_DAT'</b>

EXPORTING

FILE_NAME = 'c:\actual.xls'

  • CREATE_PIVOT = 0

  • DATA_SHEET_NAME = ' '

  • PIVOT_SHEET_NAME = ' '

  • PASSWORD = ' '

  • PASSWORD_OPTION = 0

TABLES

  • PIVOT_FIELD_TAB =

DATA_TAB = T_EXCEL2

FIELDNAMES = FLDITAB

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_FILENAME = 6

INVALID_PIVOT_FIELDS = 7

DOWNLOAD_PROBLEM = 8

OTHERS = 9.