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: 

Headers for excel file through GUI_DOWNLOAD

Former Member
0 Kudos

Hi all,

How to maitain headers to excel file which is downloaded from SAP through

GUI_DOWNOAD,

Its urgent anybody let me know

7 REPLIES 7

Former Member
0 Kudos

Hi,

The function module does not have a facility of directly downloading the two together, however there is a work around.

First you create an internal table which has only one record that contains all the headers for the columns.

Download this file into your required destination file on presentation server.

Then, you download the actual internal table into the same file using GUI_DOWNLOAD, but mark APPEND = 'X' in the function module.

What this will do is, first download the headers into a file on PS and then append the records in the second download to the same file.

Why we cant do it in the same run is because, if an internal table has a column contianing quantity vlaue e.g. weight, we cannot populate the header in this column, because its character.

Try this.

Cheers,

Aditya

0 Kudos

Hi Aditya,

Thank you for Prompt response.

But what should i declare the header internal table as length 200.

but it not showing the headings.

Will you to send me technical coding

how to write the code.

Its urgent yaar.

please send the code

0 Kudos

hi madhavi

Check out the code given below (for inserting headers using

GUI_DOWNLOAD). If you want to insert headers while using

GUI_DOWNLOAD, you have to denote the file type as DBF.

And also define an internal table for header and populate it with whatever

header you want and pass it on to the function as value for FIELDNAMES

in the TABLES part.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'c:\gui.xls'

FILETYPE = 'DBF'

  • APPEND = 'X'

WRITE_FIELD_SEPARATOR = '#'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = 'X'

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = 'IBM'

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

IMPORTING

FILELENGTH = fsize

TABLES

DATA_TAB = TAB " internal table containing data

FIELDNAMES = name " internal table containing headers

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.

write / 'error'.

ENDIF.

_________________

Thanks and Regards,

0 Kudos

Hi ,

I am working in 4.6 c version.

In that there is no table name fieldnames.

Please help me in 4.6c

0 Kudos

DATA: BEGIN OF itab1 OCCURS 0,

f1(10),

END OF itab1.

itab1-f1 = 'Field 1'.

APPEND itab1.

itab1-f1 = 'Field 2'.

APPEND itab1.

itab1-f1 = 'Field 3'.

APPEND itab1.

itab1-f1 = 'Field 4'.

APPEND itab1.

itab1-f1 = 'Field 5'.

APPEND itab1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:test.xls'

filetype = 'ASC'

write_field_separator = 'X'

TABLES

data_tab = itab

fieldnames = itab1

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.

Edited by: Abap-fresher on Feb 25, 2008 12:32 PM

0 Kudos

another way to do this is :

1.First populate the data into your internal table.

2. Now insert the Text in the header of the Internal Table( Sy-tabix = 1) index =1

3. Append the data.

You would see the header is populted into the internal table.

4. Now Download the Internalt table into the EXCEL.

0 Kudos

Hi,

I wouldnt suggest GUI_DOWNLOAD if you want a proper EXCEL Sheet. GUI_DOWNLOAD cannot create a proper excel sheet, it actually creates a tab delimited file hence you can open it using notepad also, I suggest to go for the function module XXL_ALV_CALL..which gives you a proper EXCEL sheet to save

santhosh kaluvala