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: 

FUNCTION MODULE FOR DOWNLOAD

Former Member
0 Kudos

Can u guys suggest me whch Function Module to be used to DOWNLOAD

data from an INTERNAL TABLE to an EXCEL file.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi John,

Use <b>GUI_DOWNLOAD.

ex:

  • Download the File.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = V_FILENAME " name of the file

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = '#' "tab seperator you can put ',' instead

TABLES

DATA_TAB = I_ERR_REC "internal table from which data is obtained

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.

Reward points if this helps,</b>

Kiran

10 REPLIES 10

Former Member
0 Kudos

hi,

U can use GUI_DOWNLOAD and u assign the file type as '.xls'.

former_member194669
Active Contributor
0 Kudos

Hi,

There is no direct function module to download to excel.

But you can use fm GUI_DOWNLOAD

or you can try with XXL_FULL_API

aRs

sharadendu_agrawal
Active Participant
0 Kudos

use gui_download and give the file name with the ext .xls.

reward if helpful.

cheers

sharadendu

Former Member
0 Kudos

Hi John,

Use <b>GUI_DOWNLOAD.

ex:

  • Download the File.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = V_FILENAME " name of the file

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = '#' "tab seperator you can put ',' instead

TABLES

DATA_TAB = I_ERR_REC "internal table from which data is obtained

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.

Reward points if this helps,</b>

Kiran

uwe_schieferstein
Active Contributor
0 Kudos

Hello John

With respect to <b>Unicode </b>we should no longer use the function modules for download/upload to/from the presentation server (= local PC) but instead use method <b>CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD</b> (and GUI_UPLOAD, respectively).

Regards

Uwe

Former Member
0 Kudos

where to give the file type as XLS ?

0 Kudos

Hi,

I think you cannot able to give filetype as XLS

Just give your file name as C:\TEMP\TEST.XLS

Available Types are

'ASC' :

ASCII format. The table is transferred as a text. Here, conversion exits are executed. The output format also depends on the parameters CODEPAGE, TRUNC_TRAILING_BLANKS, and TRUNC_TRAILING_BLANKS_EOL.

'IBM' :

ASCII format with IBM code page conversion (DOS). This format corresponds to the 'ASC' format, with use of target code page 1103. This code page is often used for data exchange by floppy disk.

'DAT' :

Transmission column by column. In this format, the data is transmitted just like ASCals text. However, no conversion exists are executed, and the columns are separated using tab characters. This format creates files that can be imported again using gui_upload or ws_upload.

'DBF' :

The data is downloaded in dBase format. With this format, the data types are stored as well, For this reason, import problems can be avoided - for example, problems with Microsoft Excel. In particular, you can avoid problems with the interpretation of numeric values.

'WK1' :

The data is downloaded in Lotus 1-2-3 format.

'BIN' :

Binary format. The data is transmitted in binary form. There is no editing and no code page conversion. The data is interpreted line by line and not column by column. The length of the data must be specified in the BIN_FILESIZE parameter. The table should consist of a column of type X, since - in Unicode systems - the conversion of structured data to binary data can cause errors.

aRs

0 Kudos

Hi John,

generally CSV i.e. comma separated value files are stored as .XLS file.

so for the parameter <b>WRITE_FIELD_SEPARATOR</b> assign ',' you shall get your desired result.

<b>Reward points if this helps,</b>

Kiran

Former Member
0 Kudos

hi,

U have to give it in the filename u r giving.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'test.xls'

tables

data_tab =

.

Former Member
0 Kudos

Hello,

You can use

<b>GUI_DOWNLOAD

or

SAP_CONVERT_TO_XLS_FORMAT</b>

reward if helpful,

Regards,

LIJO