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: 

Download Excel including header

Former Member
0 Kudos

Dear Experts,

I am using FM GUI_Download. is working fine. But Body of the records will be downloaded.HEADER Data is not downloaded in the excel file.

for eg.

MATNR MATKL --->DO NOT DOWNLOADED

01255 test --->Downloaded.

45445 hi -->Downloaded.

NOTEL: FM GUI_DOWNLOAD (HEADER one field available) How to use it?

ASP.

Warm Regards,

raj.a

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

You have to use the TABLE FIELDNAMES of GUI_DOWNLOAD for this purpose.

Try this:


TYPES:  
BEGIN OF ty_xlhead,
  fld TYPE char40,         "For header name
END OF ty_xlhead.

DATA: 
it_xlhead TYPE STANDARD TABLE OF ty_xlhead,
wa_xlhead TYPE ty_xlhead.

  CLEAR wa_xlhead.
  wa_xlhead-fld  = 'MATNR'.
  APPEND wa_xlhead TO it_xlhead.

  CLEAR wa_xlhead.
  wa_xlhead-fld  = 'MATKL'.
  APPEND wa_xlhead TO it_xlhead.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                = l_v_filename
    write_field_separator   = l_c_x
    dat_mode                = l_c_x
    confirm_overwrite       = l_c_x
  TABLES
    data_tab                = it_excel
    fieldnames              = it_xlhead "--> Header Data
  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.

Hope this helps.

BR,

Suhas

Edited by: Suhas Saha on Jan 28, 2009 4:46 PM

6 REPLIES 6

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

You have to use the TABLE FIELDNAMES of GUI_DOWNLOAD for this purpose.

Try this:


TYPES:  
BEGIN OF ty_xlhead,
  fld TYPE char40,         "For header name
END OF ty_xlhead.

DATA: 
it_xlhead TYPE STANDARD TABLE OF ty_xlhead,
wa_xlhead TYPE ty_xlhead.

  CLEAR wa_xlhead.
  wa_xlhead-fld  = 'MATNR'.
  APPEND wa_xlhead TO it_xlhead.

  CLEAR wa_xlhead.
  wa_xlhead-fld  = 'MATKL'.
  APPEND wa_xlhead TO it_xlhead.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                = l_v_filename
    write_field_separator   = l_c_x
    dat_mode                = l_c_x
    confirm_overwrite       = l_c_x
  TABLES
    data_tab                = it_excel
    fieldnames              = it_xlhead "--> Header Data
  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.

Hope this helps.

BR,

Suhas

Edited by: Suhas Saha on Jan 28, 2009 4:46 PM

Former Member

Former Member
0 Kudos

Hi,

Use this Function Module, its a bit easier.

call function 'MS_EXCEL_OLE_STANDARD_DAT'

exporting

file_name = filename

tables

  • PIVOT_FIELD_TAB =

data_tab = gt_itabe " internal table

  • FIELDNAMES = it_fieldnames

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.

Thanks & Regards,

Adithya M

tarangini_katta
Active Contributor
0 Kudos

HI,

u have the tables parameter FIELDNAMES in gui_downlaod.INthe import parametr.

Uncommet the header .pass u r fieldnames to u r tables parameters.

then it will work for you.

Thanks

sujeet2918
Active Contributor
0 Kudos

Hello Raj,

Use two GUI_DOWNLOAD FM.

First you create Header and put in one internal table.that is it_header.

second, create internal table for your data that is it_data

now first call GUI_DOWNLOAD FM like below for passing your header.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = it_header

  • FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = it_final

second call again for data

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = file_name

  • FILETYPE = 'ASC'

APPEND = ' X' " use this to append your header

  • WRITE_FIELD_SEPARATOR = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = it_final

Have a Nice Day,

Regards,

Sujeet