Header in 'gui_download'

Hi All,
I use 'GUI_DOWNLOAD' to download data from internal table to excel.I am passing the heading in the header field of function module.
call FUNCTION 'GUI_DOWNLOAD'
EXPORTING
      FILENAME                = lv_file
      FILETYPE                = 'ASC'
      write_field_separator   = 'X'
      header                  = lv_header
    TABLES
      data_tab                = t_output.
header is of type XTRING in the function module.
if i declare my variable as type string it shows a runtime dump due to type mismatch.
I am not able to declare it as type xstring.can anyone advice on how to declare a variable as type xstring or any other way to solve my problem.
Thanks & Regards,
Subasree

try this
data:begin of excel_heading,
    text(20) type c,
    end of excel_heading.
    data:it_heading like standard table of excel_heading initial size 0.
*--Generate the heading for excel data
    excel_heading-text = 'A'.
    append excel_heading to it_heading.
    excel_heading-text = 'B'.
    append excel_heading to it_heading.
    excel_heading-text = 'C'.
    append excel_heading to it_heading.
    excel_heading-text = 'D'.
    append excel_heading to it_heading.
    call function 'GUI_DOWNLOAD'
      exporting
        filename              = p_pfile
        filetype              = 'DAT'
        write_field_separator = '#'
        header                = '00'
        trunc_trailing_blanks = 'X'
        show_transfer_status  = 'X'
      tables
        data_tab              = p_it_final[]
        fieldnames            = it_heading[].

Similar Messages

  • Download Header using GUI_DOWNLOAD for more than 100 fields

    Hi,
    I want to download data with header from a database table using the FM 'GUI_DOWNLOAD'.
    I know that this can be achieved by
    1. Download headers first to an internal table and call FM ' GUI_DOWNLOAD" 
    2. then Download data to the same file by calling FM 'GUI_DOWNLOAD' with APPEND = 'X'
    But my database table has more than 100 fields, pls tell me how to download all the fields as header information.
    Thanks in advance.

    Hi
    This can be done using the FM GUI_DOWNLOAD.
    Store all the field names in a internal table, pass the internal table to FIELDNAMES component of the FM. This will download the internal table with headings.
    Note - To download it as excel, pass FILETYPE as 'DAT'.
    Regards,
    Vinod

  • Header with Gui_download

    Hi,
    I am downloading the data into excel using GUI_DOWNLOAD.
    I have header information. When i checked the data the header information is condensing with respect to data.
    Even i increased the  length specification still it is condensing with respect to data. I have used File Type as DBF becuase ASC is not working.
    I would like to have without condensing the descriptions.
    Is there any alternative to download the datawithout this FM or any class available.
    Please do the needful ASAP.
    Thanks,
    Krishna.

    Hi Try this...
        PERFORM SET_IS_LIST_DOWNLOAD(SAPLGRAP) USING 'x'.
        PERFORM GET_LISTLEVEL_TABLES USING
                                     PAGES[]
                                     LIST[]
                                     FMBS[]
                                     FMBX[]
                                     FSEL[]
                                     LIST_INDEX.
        CALL FUNCTION 'LIST_CONVERT_TO_DAT'
          TABLES
            LIST = LIST[]
            FMBS = FMBS[]
            FMBX = FMBX[]
            FSEL = FSEL[].
        PERFORM SET_IS_LIST_DOWNLOAD(SAPLGRAP) USING ' '.
    FORM SET_IS_LIST_DOWNLOAD USING TAG TYPE C.
      GLOBAL_IS_LIST_DOWNLOAD = TAG.
    ENDFORM.
    form get_listlevel_tables using
                               pages    type slist_pagedescr_tab
                               lines    type slist_list_tab
                               fmbs     type slist_fmbs_tab
                               fmbx     type slist_fmbs_tab
                               fsel     type slist_fsel_tab
                               list_index type i.
      data: stack type slist_listlevel_stack with header line,
            listlevel type slist_listlevel.
      data tab_index_liststack type i.
      field-symbols: <tabh>.
      if list_index < 0.
        raise list_index_invalid.
      endif.
      system-call load listlevel-stack into stack.
      tab_index_liststack = list_index + 1.
      read table stack index tab_index_liststack into listlevel
                                     transporting listobject-listtab
                                                  listobject-fmbstab
                                                  listobject-fmbxtab
                                                  listobject-fseltab
                                                  listobject-pagetab.
      if sy-subrc <> 0.
        raise list_index_invalid.
      endif.
      system-call assign lines[]  to <tabh> type 'X'.
      <tabh>  = listlevel-listobject-listtab.
      system-call assign fmbs[]  to <tabh> type 'X'.
      <tabh>  = listlevel-listobject-fmbstab.
      system-call assign fmbx[]  to <tabh> type 'X'.
      <tabh>  = listlevel-listobject-fmbxtab.
      system-call assign fsel[]  to <tabh> type 'X'.
      <tabh>  = listlevel-listobject-fseltab.
      system-call assign pages[]  to <tabh> type 'X'.
      <tabh>  = listlevel-listobject-pagetab.
    endform.                    "GET_LISTLEVEL_TABLES
    FORM SET_IS_LIST_DOWNLOAD USING TAG TYPE C.
      GLOBAL_IS_LIST_DOWNLOAD = TAG.
    ENDFORM.
    Thanks,
    Gaurav J.

  • How to post a header using GUI_DOWNLOAD

    hello:
    i would like to ask one favor, i trying to download a fiel to a PC i am using the GUI_DOWNLOAD function when i sent the it_table to the function this works well , but now i need to sent the name of the colums for each colums, i sending a tables with the names of that colums but the function is sending an error.
    CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename          = nombre
              filetype          = 'ASC'
              confirm_overwrite = 'X'
            TABLES
              data_tab          = t_itab2
              fieldnames        = t_fieldnames. HERE SEND THE ERROR MSG.
    note: this file is gonna be download from ITS that why iam using the GUI_DOWNLOAD.
    please does anybody knows how to send the names of the colums for one file using this function?
    thanks a lot for you help.

    If you are using a newer system, then the GUI_DOWNLOAD funciton module does contain a TABLES parameter for fieldnames.  Here is an example.
    REPORT  zrich_0001.
    TYPES: BEGIN OF t_fldnames,
           fldname(30) type c,
           END OF t_fldnames.
    DATA: ifldnm TYPE TABLE OF t_fldnames WITH HEADER LINE.
    DATA: ispfli TYPE TABLE OF spfli.
    SELECT * INTO TABLE ispfli FROM spfli.
    ifldnm-fldname = 'Client'.     append ifldnm.
    ifldnm-fldname = 'Airline Code'. append ifldnm.
    ifldnm-fldname = 'Flight Connection Number'. append ifldnm.
    ifldnm-fldname = 'Country Key'.   append ifldnm.
    ifldnm-fldname = 'Departure city'.  append ifldnm.
    ifldnm-fldname = 'Departure airport'.  append ifldnm.
    ifldnm-fldname = 'Country Key'.  append ifldnm.
    ifldnm-fldname = 'Arrival city'.  append ifldnm.
    ifldnm-fldname = 'Destination airport'.  append ifldnm.
    ifldnm-fldname = 'Flight time'.  append ifldnm.
    ifldnm-fldname = 'Departure time'.  append ifldnm.
    ifldnm-fldname = 'Arrival time'.  append ifldnm.
    ifldnm-fldname = 'Distance'.  append ifldnm.
    ifldnm-fldname = 'Mass unit of distance (kms, miles)'.  append ifldnm.
    ifldnm-fldname = 'Flight type'.  append ifldnm.
    ifldnm-fldname = 'Arrival n day(s) later'.   append ifldnm.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename              = 'c:/test.xls'
        write_field_separator = 'X'
      TABLES
        data_tab              = ispfli
        fieldnames            = ifldnm.
    This parameter is  not supported in a 46c system
    Regards,
    Rich Heilman

  • Heading  during downloading into local file using GUI_DOWNLOAD fun.module

    Hi Guru's
    we have a requirement that we want the plant description as a heading (first line of the file) in the local file. iam using "GUI_DOWNLOAD" function module for downloading data for which iam passing the charecter type internal table. before downloading iam passing all the filed headings to that table and then appending the internal table data into it. now iam getting data properly with field headings . but before that heading i want one more description for a plant field which iam using in my selection screen
    in the fun.module "GUI_DOWNLAOD"
    we have HEADER file but it is of XSTRING type so it is taking only 2 char.
    so how to use this . Plz help me.
    thanks well in advance.
    UR's
    GSANA

    Hi,
    Please check the below link,
    header in 'gui_download'
    Also check Manoj kumar's reply in the link,
    header information to gui_download
    Hope this helps.
    Best Regards.

  • Using fieldnames table in GUI_DOWNLOAD method

    Hi Experts,
    I need to download an itab data with field names as headers. I am using this but getting error 'Formal parameter "FIELDNAMES" does not exist. However, the parameter "FILENAME" has a similar name'.
    CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = w_filenm
          filetype                = c_filetype
          write_field_separator   = c_x
        CHANGING
          data_tab                = i_bsak[]
          fieldnames              = i_field[]
        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
          not_supported_by_gui    = 22
          error_no_gui            = 23
          OTHERS                  = 24.
    Please let me know how can i get file header using GUI_DOWNLOAD method.
    Thanks in adv
    Akash

    Hi
    Say for example I'm downloading a internal table with 4 fields namely field1, field2, field3 and field4.
    I want these field name in the header, then this is the way to do it.
    TYPES: BEGIN OF ty_head, "Structure for header
                 h(10) TYPE c,
                 END OF ty_head.
    DATA: it_head  TYPE TABLE OF ty_head WITH HEADER LINE.
    "Adding header details
    it_head-h = 'Field1'.
    APPEND it_head.
    it_head-h = 'Field2'.
    APPEND it_head.
    it_head-h = 'Field3'.
    APPEND it_head.
    it_head-h = 'Field4'.
    APPEND it_head.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = p_file
       filetype                        = 'ASC'
       write_field_separator           = 'X'
       header                          = '00'  "<= note this
      TABLES
        data_tab                        = it_tab
       fieldnames                      = it_head[] "<= Pass your header table here
    EXCEPTIONS
       OTHERS                          = 1.
    Hope this helps.
    Thx and regrds
    Durga.K

  • How to put the header in excel file in GUI_DOWNLOAD

    Hi,
    I have a requirement , Which I m downloading the contents of internal table using the GUI_DOWNLOAD  in excel format, I need to keep the first line of the excel sheet as a header, Can any one suggest how to go for this,

    Hello,
    You can have the data in the data tab & field name in the field tab. And so you can download both the field name and the value for the same using the FM u2013 GUI_DOWNLOAD (File type should be u2018ASCu2019).
    Hope, you need additional information to be added as the header.
    One option: You can call the GUI_UPLOAD twice.
    First one with the header in the data tab.
    Second one with the option append = u2018Xu2019 with the actual data and header and pass the same above file name as input.
    Also, there is a solved forum already exists but with a different solution. You can go through the below link also:
    Re: GUI_DOWNLOAD with Header
    Regards,
    Selva K.

  • Header getting repeated in GUI_DOWNLOAD

    Hi,
    I am downloading a report output to local file on PC.
    For this I'm using FM GUI_DOWNLOAD with file type as 'DAT'.
    If the no. records in the table, that i am passing to the FM, are more than 30,000 then the header (which am passing to FM through 'Fieldnames') is getting repeated after every 9810 row.
    Please suggest me how to get the header displayed only once as in this case it is getting displayed 4 times in the downloaded file (text file as well as excel file).
    Thanks,
    Inder

    Hi,
    Sure it is unusual.
    have you checked whether the "header" was not repeated in the internal table itself?
    Best regards,
    Guillaume

  • Cl_gui_frontend_services= gui_download, header and data in text file

    CALL METHOD cl_gui_frontend_services=>gui_download        EXPORTING
        filename                = c:\abc.txt
        filetype                = 'ASC'
         write_field_separator  = space                        
       HAS_FIELD_SEPARATOR     = SPACE
       HEADER_LENGTH           = 0
       DAT_MODE                = SPACE
       CODEPAGE                = 'ASC'                      
       IGNORE_CERR             = ABAP_TRUE
       REPLACEMENT             = '#'
       READ_BY_LINE            = 'X'
    IMPORTING
       FILELENGTH              =
       HEADER                  =
      CHANGING
        data_tab                = t_pch[]
    here the file abc.txt get some text as header.
    butwhen i want write actual data again witht he same file name the file get over writed
    CALL METHOD cl_gui_frontend_services=>gui_download    
      EXPORTING
        filename                = c:\abc.txt
        filetype                = 'ASC'
         write_field_separator  = space                       
       HAS_FIELD_SEPARATOR     = SPACE
       HEADER_LENGTH           = 0
       DAT_MODE                = SPACE
       CODEPAGE                = 'ASC'                      
       IGNORE_CERR             = ABAP_TRUE
       REPLACEMENT             = '#'
       READ_BY_LINE            = 'X'
    IMPORTING
       FILELENGTH              =
       HEADER                  =
      CHANGING
        data_tab                = t_pc[]

    Hi
    When second time you call method just add the following
    CALL METHOD cl_gui_frontend_services=>gui_download
         EXPORTING
           filename                  = v_value
           append                    = 'X'        <------- Just add this line

  • Need to extend header length in Excel file being downloaded by GUI_DOWNLOAD

    hello Experts,
    I have written a program where the data from DSO is downloaded into Excel File which is being saved on my desktop.
    Now, i am facing one problem with the length of header and the values.
    For eg:
    I have 15 cloumns and i have given description for each column ie header name. This header is being displayed only upto 255 characters. If the total length of all the columns header desc exceeds 255 char, then blank header is displayed further.
    Same is the case with the values of the columns.
    I am pasting the relevant code.
    The code for displaying header and fields is:
    Concatenate
    'Sales Org'
    'Sales Org Desc'
    'Sales Dist'
    'Sales Dist Desc'
    'Sales Rep'
    'Sales Rep Desc'
    'Customer Number'
    'Customer Desc'
    'Billing Document'
    'AGI Code No'
    'AgiCode Desc'
    'UCAGI Code No'
    'UCAGI Code Desc'
    'Design Code'
    'CalMonth'
    'CalYear'
    'Billing Qty'
    'ZDIF'
    'ZE01'
    'ZE13'
    Into ls_contents-line SEPARATED BY lc_tab.
    APPEND ls_contents TO lt_contents.
    CLEAR ls_contents.
    Loop at i_t_Table into wa_i_t_t_Table.
    concatenate
          wa_i_t_t_Table-/BIC/G00000574
          wa_i_t_t_Table-salesorg_name
          wa_i_t_t_Table-/BIC/G00000514
          wa_i_t_t_Table-salesdist_name
          wa_i_t_t_Table-/BIC/G00009361
          wa_i_t_t_Table-SalesRep_name
          wa_i_t_t_Table-/BIC/G00000466
          wa_i_t_t_Table-Customer_name
          wa_i_t_t_Table-/BIC/G00000464
          wa_i_t_t_Table-/BIC/G00000001
          wa_i_t_t_Table-agicode_name
          wa_i_t_t_Table-/BIC/G00000002
          wa_i_t_t_Table-UCagicode_name
          wa_i_t_t_Table-/BIC/G00000005
          wa_i_t_t_Table-CALMONTH2
          wa_i_t_t_Table-CALYEAR
          wa_i_t_t_Table-/BIC/G00001108
          wa_i_t_t_Table-/BIC/G00021022
          wa_i_t_t_Table-/BIC/G00021023
          wa_i_t_t_Table-/BIC/G00021024
    INTO ls_contents-line SEPARATED BY lc_tab.
    *CONCATENATE ls_contents lv_hex1 INTO ls_contents.
              APPEND ls_contents TO lt_contents.
              CLEAR ls_contents.
    ENDLOOP.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
       FILENAME                        = c_filename
    FILETYPE                        = 'DAT'
      APPEND                          = ' '
       WRITE_FIELD_SEPARATOR           = ' '
    HEADER                          = '01'
      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'
      WK1_N_FORMAT                    = '0'
      WK1_N_SIZE                      = '20'
      WK1_T_FORMAT                    = '0'
      WK1_T_SIZE                      = '20'
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
      SHOW_TRANSFER_STATUS            = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
      TABLES
        DATA_TAB                        = lt_contents
      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.
    Note:  Gone through SDN where many things are suggested like to use parameter of GUI_DOWNLAOD ie "FIELDNAMES " which is disabled in my SAP version.
    Please suggest how to make all the headers and the values of the fields properly.
    Would appreciate immediate help.
    Thanks in advance.
    Regards
    Lavanya

    solved.

  • Need to include header in csv file while using GUI_DOWNLOAD

    Hi,
    Iam using GUI_DOWNLOAD for downloading certain texts,its working fine.now i need to include the header(i'e) some text say 'This is a error file'at the top.how can i do this?

    REPORT  ZTEST12347                              .
    DATA: BEGIN OF ITAB OCCURS 0,
            VBELN LIKE VBAK-VBELN,
            POSNR LIKE VBAP-POSNR,
          END OF ITAB.
    SELECT VBELN
           POSNR
          FROM VBAP
          UP TO 20 ROWS
          INTO TABLE ITAB.
    DATA: IT_LINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
    IT_LINE-TDLINE = 'this is error file'.
    append it_line.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                = 'C:test.txt'
      TABLES
        DATA_TAB                = IT_LINE
      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.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                = 'C:test.txt'
        APPEND                  = 'X'
      TABLES
        DATA_TAB                = ITAB
      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.

  • Problem gui_download  -Data looks messy without proper column header

    Dear SDNers,
    Scenario:
    Using FM GUI_download to download excel file to Presentation server.
    Excel file downloads perfecly fine on presentation server with proper column headers when the OS is not XP/Vista.
    Issue:
    when i run this program on my system having Windows Vista,Excel downloads but the column header is all jumbled up without proper differetation.
    Kindly let me know what the the issue could be?
    My Effort:
    I did some googling and found that in Function Modules GUI_DOWNLOAD and GUI_UPLOAD.
    The form of the file name depends on the underlying operating system.
    To make your programs portable to different operating systems, we should use the function module FILE_GET_NAME.
    which returns the system-dependent name for an abstract file name.
    Kindly let me know if this is correct.
    Reason am asking is now i dont have access to code and check the same since i dont have authorization.
    Regards,
    SuryaD.
    Edited by: SuryaD on Jan 12, 2010 2:20 PM

    No response.So closing the thread.

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • Regarding header proble in FM GUI_download.

    Hi,
    I want to write header in XL file by using the paramter fieldnames, but the FM is not considering full text what i m giving ,
    please see the below code
    *To download
    DATA : BEGIN OF t_header OCCURS 0,
           name(100) TYPE c,
           END OF t_header.
    DATA : BEGIN OF itab OCCURS 0,
           fld1(100) TYPE c,
           fld2 TYPE char10,
           fld3 TYPE char10,
           END   OF itab.
    DATA: v_pass_path TYPE string.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welsuresh'.
    APPEND itab.
    CLEAR itab.
    itab-fld3 = 'welcome'.
    APPEND itab.
    t_header-name = 'Field1 for sure and ucb and acc'.
    APPEND t_header.
    t_header-name = 'Field2'.
    APPEND t_header.
    t_header-name = 'Field3'.
    APPEND t_header.
    v_pass_path = 'P:\Suresh\UCB\Incidents\INC - sanjay - pooja\File from pooja\suresh.xls'.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = v_pass_path
        filetype                        = 'DBF'       " This is important
    *for XL download
       APPEND                          = 'X'
      WRITE_FIELD_SEPARATOR           = 'X'
        header                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
        WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = 'X'
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      =
      TABLES
        data_tab                        = itab
        fieldnames                      = t_header.
    thanks,
    Suresh

    Hi Suresh,
    Try to replicate through this code,
    TABLES: sflight.
    DATA:
      BEGIN OF t_sflight OCCURS 0,
      carrid TYPE sflight-carrid,
      connid(5) TYPE c,
      fldate TYPE sflight-fldate,
      seatsmax TYPE sflight-seatsmax,
      seatsocc TYPE sflight-seatsocc,
      END OF t_sflight.
    DATA:
      BEGIN OF t_header OCCURS 0,
      header(50) TYPE c,
    END OF t_header.
    PARAMETERS: p_carr TYPE sflight-carrid.
    *DATA: t_sflight TYPE TABLE OF sflight WITH HEADER LINE.
    SELECT carrid connid fldate seatsmax seatsocc
      FROM sflight
    INTO TABLE t_sflight
    WHERE carrid = p_carr.
    t_header-header = 'Carrid'.
    APPEND t_header.
    t_header-header = 'Connid'.
    APPEND t_header.
    t_header-header = 'Fldate'.
    APPEND t_header.
    t_header-header = 'Max'.
    APPEND t_header.
    t_header-header = 'Min'.
    APPEND t_header.
    LOOP AT t_sflight .
      WRITE: / t_sflight-carrid,
      t_sflight-connid,
      t_sflight-fldate,
      t_sflight-seatsmax,
      t_sflight-seatsocc.
    ENDLOOP.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename   = 'C:\My Documents\temp\test.xls'
        filetype   = 'DAT'
      TABLES
        data_tab   = t_sflight
        fieldnames = t_header.
    Regards
    Adil

  • Displaying header in excel horizontally using FM GUI_DOWNLOAD

    Dear Experts,
            I'm exporting my data to an excel file using GUI_DOWNLOAD.  The problem is that I'm having problems with exporting the headings of my excel.  I can export the heading but the problem is that it is displayed vertically and not horizontally.
    Is there a way I could display the heading horizontally?  Hope you could help me.
    Below is my program.
    DATA: BEGIN OF itab OCCURS 0,
                  DVNO TYPE ZPFHEADER-DVNO,
                  EMPNO(8),
                  EMPNAME LIKE PA0002-CNAME,
                  LTYPE LIKE it_header-wtype,
                  LCODE LIKE it_header-dkond,
                  MA(6) TYPE p DECIMALS 2,
                  APRVDATE(15),
                  DTL LIKE ZPFHEADER-DVNO,
              END OF itab.
    DATA: BEGIN OF header OCCURS 0,
                  head1(15) TYPE c,
                  head2(15) TYPE c,
              END OF header.
    PERFORM DISPLAY_DATA.
          FORM DISPLAY_DATA                                             *
    FORM DISPLAY_DATA.
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
              i_callback_program = g_repid
              I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
              I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
              is_layout          = gs_layout
              it_fieldcat        = gt_fieldcat[]
              it_events          = gt_events[]
            TABLES
              t_outtab           = jtab.
    ENDFORM.
    *&      FORM USER_COMMAND
          COMMAND for ALV Grid Buttons
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    PERFORM write_header.
    CASE r_ucomm.
      WHEN 'XCEL'.
        CONCATENATE: 'C:\' fname sy-datum INTO fname.
        CONCATENATE: fname '.XLS' INTO FILENAME.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            FILENAME = FILENAME
            HEADER = '00'
            WRITE_FIELD_SEPARATOR = 'X'
          TABLES
            DATA_TAB   = header
            FIELDNAMES = header.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            FILENAME = FILENAME
            APPEND   = 'X'
            WRITE_FIELD_SEPARATOR = 'X'
          TABLES
            DATA_TAB = jtab
          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.
          ELSEIF sy-subrc = 0.
            MESSAGE S000(38) WITH 'File ' fname 'saved in Drive C.'.
          ENDIF.
    ENDCASE.
    ENDFORM.
    *&      Form  write_header
          text
    -->  p1        text
    <--  p2        text
    FORM write_header.
    DATA: ctr(2) TYPE N.
    DO 6 TIMES.
      ADD 1 TO ctr.
      CASE ctr.
        WHEN 1. header-head1 = 'EMPLOYEE'.
                header-head2 = ' NO '.
        WHEN 2. header-head1 = 'EMPLOYEE'.
                header-head2 = ' NAME '.
        WHEN 3. header-head1 = 'LOAN'.
                header-head2 = 'TYPE'.
        WHEN 4. header-head1 = 'APPROVAL'.
                header-head2 = ' DATE '.
        WHEN 5. header-head1 = 'LOAN'.
                header-head2 = 'CODE'.
        WHEN 6. header-head1 = ' MONTHLY '.
                header-head2 = 'AMORTIZATION'.
      ENDCASE.
      APPEND header.
      CLEAR: header.
    ENDDO.
    The output should be something like this as shown below:
    Employee     Employee                     Loan     Approval     
    Number     Name                     Type     Date     
    6633     ABAD, JUSTINA     DVP1     2-Apr-07

    Hi,
    Check this sample code:
    REPORT  ZSW_DOWNLOAD_HEADER.
      DATA : itab LIKE TABLE OF t001 WITH HEADER LINE.
      SELECT * FROM t001 INTO TABLE itab.
      PERFORM mydownload TABLES itab USING 'C:\t001.txt'.
      FORM mydownload TABLES ptab USING filename.
    DAta
    *DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.
        DATA: dfies_tab LIKE dfies OCCURS 0 WITH HEADER LINE.
        DATA : allfields(300) TYPE c.
        DATA : fld(100) TYPE c.
        DATA : BEGIN OF htab OCCURS 0,
        allfields(300) TYPE c,
        END OF htab.
        CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
        tabname = 'T001'
    FIELDNAME = ' '
    LANGU = SY-LANGU
    LFIELDNAME = ' '
    ALL_TYPES = ' '
    GROUP_NAMES = ' '
    UCLEN = UCLEN
    IMPORTING
    X030L_WA = X030L_WA
    DDOBJTYPE = DDOBJTYPE
    DFIES_WA = DFIES_WA
    LINES_DESCR = LINES_DESCR
        TABLES
        dfies_tab = dfies_tab
    FIXED_VALUES = FIXED_VALUES
    EXCEPTIONS
    NOT_FOUND = 1
    INTERNAL_ERROR = 2
    OTHERS = 3
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        LOOP AT dfies_tab.
          CONCATENATE dfies_tab-fieldtext
          cl_abap_char_utilities=>horizontal_tab INTO fld.
          CONCATENATE allfields fld INTO allfields .
        ENDLOOP.
        htab-allfields = allfields.
        APPEND htab.
    download first field list
        CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
    BIN_FILESIZE =
        filename = 'c:\t001.xls'
        filetype = 'DAT'
        write_field_separator = 'X'
        TABLES
        data_tab = htab.
    then download file data
        CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
    BIN_FILESIZE =
        filename = 'c:\t001.xls'
        filetype = 'DAT'
        append = 'X'
        write_field_separator = 'X'
        TABLES
        data_tab = ptab.
      ENDFORM.                    "mydownload

Maybe you are looking for

  • Acrobat Pro. 7.1.0 problem with Windows 7

    Hello, I recently upgraded my desktop to Windows 7 64 bit.  Prior to that, I had been running Vista Home Premium 64 bit. Acrobat runs, and I can read Acrobat documents, so that is working.  However, when I go to "Devices and Printers", I don't have t

  • Agent Determination in Workflow

    Hi, I am implementing a workflow for change in basic pay, the problem is i am not clear how to go about agent determination,  i need to follow my organizational structure but not completely like its not like the complete hierarchy. I need ideas, and

  • Use tv as pc monitor

    how can i connect my vista pc and use my apple tv as a monitor??

  • Anybody having trouble ordering thru apple?

    I ordered the new IPhone yesterday thru the apple store app. They gave me a reservation number then an e-mail telling me to complete my order. So I called and completed my order they said that I should receive two emails which I did. They said one of

  • Searching Photos in Spotlight for in iOS4

    I have a ton of photos on my iPhone 4 but would like to be able to include my photo keywords or photo events in spotlight. Is there now way to do this or is there an app that someone knows about that allows for this? Cheers!