GUI_DOWNLOAD -- WRITE_FIELD_SEPARATOR

Hi,
I am using this code to save/download table to txt file.
I am using WRITE_FIELD_SEPARATOR = ';' but stil separator is SPACE??
Can someone help. plz..
  DATA: ldf_filename TYPE string,
  ldf_path TYPE string,
  ldf_fullpath TYPE string,
  ldf_fname TYPE string.
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
  EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
  default_file_name = ldf_fname
* FILE_FILTER =
* INITIAL_DIRECTORY =
* WITH_ENCODING =
* PROMPT_ON_OVERWRITE = 'X'
  CHANGING
  filename = ldf_filename
  path = ldf_path
  fullpath = ldf_fullpath
* USER_ACTION =
* FILE_ENCODING =
  EXCEPTIONS
  cntl_error = 1
  error_no_gui = 2
  OTHERS = 4.
  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
*   BIN_FILESIZE                  =
      filename                      = ldf_filename
   FILETYPE                      = 'ASC'
*   APPEND                        = ' '
   WRITE_FIELD_SEPARATOR         = ';'
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   COL_SELECT                    = ' '
*   COL_SELECT_MASK               = ' '
*   DAT_MODE                      = ' '
* IMPORTING
*   FILELENGTH                    =
    TABLES
      data_tab                      = lt_spoollst
* 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.

Hi Adibo...
Here WRITE_FIELD_SEPERATOR can be either 'X' OR ' '.
'X' means Tab delimiter will be used.
'  ' Means No delimiter
We cannot give other Characters like ; here.
So in the Internal Table itself you store the Data using this delimiter and then pass the Itab to Internal table.
DATA: IT_DATA TYPE TABLE OF STRING.
LOOP AT ITAB INTO WA.
  CONCATENATE WA-FIELD1 WA-FIELD2 SEPARATED BY ';'.
  APPEND WA TO IT_DATA.
ENDLOOP.
Now pass the DATA_TAB = IT_DATA
and               WRITE_FIELD_SEPERATOR  = ' '
<b>Reward if Helpful</b>

Similar Messages

  • Gui_download  WRITE_FIELD_SEPARATOR = 'X' .

    Hi!
    I am using the fucntion gui_download with the option WRITE_FIELD_SEPARATOR = 'X' ., i am trying to get the same file with the open dataset, i have tried with open dataset in text mode and concatenating the fields with cL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB befor transfer, but it isn´t identical.
    ¿What is the correct way?, ¿can anybody help me please?
    Thanks in advance
    Regards

    Hi!
    Thank you for your answers. My problem is that when i generate my file in local downloading an internal table with different fields i obtein different result that downloading in the presentation server.
    When i download the file with open dataset it doesn´t respect the empty separation fields marks and other difference is that in local file i can see the separation mark.
    data: begin of it_data3 occurs 0,
    field1(50),
    field2(50),
    field3(50),
    end of it_data3,
    lin(500).
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    loop at it_data3.
    concatenate field1 filed2 field3 into lin SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
    endloop.
    transfer lin to p_file.
    close dataset.
      call function 'GUI_DOWNLOAD'
            exporting
              filename                = p_file
              write_field_separator   = 'X'
            tables
              data_tab                = it_data3
            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.

  • WRITE_FIELD_SEPARATOR IN GUI_DOWNLOAD

    Hi ,
       How do i use the WRITE_FIELD_SEPARATOR field in the GUI_DOWNLOAD function.
    Arun

    Hi Arun,
    Import parameter WRITE_FIELD_SEPARATOR of function GUI_DOWNLOAD  you can use if you want fields to be seperated by tabs in downloaded file. If you pass 'X' to this parameter fields will be separated by tabs. for example i downloaded a table with this parameter as 'X' and then again with this parameter as blank. following output i got in file.
    File generated with WRITE_FIELD_SEPARATOR = ''
    1NAME1                    CITY1
    2NAME2                    CITY2
    3NAME3                    CITY3
    4NAME4                    CITY4
    5NAME5                    CITY5
    File generated with WRITE_FIELD_SEPARATOR = 'X'
    1<spaces>     NAME1 <spaces>                      CITY1
    2<spaces>     NAME2 <spaces>                      CITY2
    3<spaces>     NAME3 <spaces>                      CITY3
    4<spaces>     NAME4 <spaces>                      CITY4
    Regards,
    Komal.

  • Issue in conversion of output file from alv to csv file using GUI_DOWNLOAD

    hi,
    I am using GUI_DOWNLOAD to convert the internal table that am getting as the output of an alv into a csv(comma separated file) file.I am using the following code but its not generating a csv file instead it is generating a normal space delimited file.
    The code is as follows:
    data : lv_fname type string.
    lv_fname = 'C:\Users\pratyusha_tripathi\Desktop\status8.csv'. " Provide the file path & file name with CSV extention
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = lv_fname " File name including path, give CSV as extention of the file
    FILETYPE = 'DAT'
    WRITE_FIELD_SEPARATOR = '#' " Provide comma as separator
    tables
    data_tab = ITAB " Pass the Output internal table
    FIELDNAMES =
    EXCEPTIONS
    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.
    Kindly let me know what changes can be made to make my code work.Also can GUI_download be used for batch processing and storing the output in application server?
    Thanks ,
    Pratyusha

    Hi,
    the short text description for WRITE_FIELD_SEPARATOR is "Separate Columns by Tabs in Case of ASCII Download", so why do you expect a comma?
    Try SAP_CONVERT_TO_CSV_FORMAT and then download.
    And no, GUI_DOWNLOAD is only for download via SAP GUI to a users computer.
    Best regards,
    Oliver

  • How to get some character as a field separator while in GUI_DOWNLOAD ?

    Hi Friends,
    I have to download data from an internal table to a text file. The field separator
    between the fields should be comms (,). So, after getting the data into internal table i'm calling the Function Module GUI_DOWNLOAD. Now using this function module can i insert a comma spearator between the fields, if not what is the other way to do it?

    Hi,
    Its not possible to give the field separator as ',' directly with gui_download from you internal table.
    Below is the example through which you can achieve the following,
    this is a tested program and is working fine on the system....
    so you can use the logic to achieve the following result.... hope this logic helps you to achieve your functionality....
    DATA:
    BEGIN OF fs,
       col1(6) TYPE c,
       col2(4) TYPE c,
       col3 TYPE c,
       END OF fs.
    DATA :
    BEGIN OF line,
    line(255) TYPE c,
    END OF line.
    DATA: itab LIKE TABLE OF fs,
          itab2 LIKE TABLE OF line.
    DEFINE m_tab.
      clear fs.
      fs-col1 = &1.
      fs-col2 = &2.
      fs-col3 = &3.
      append fs to itab.
    END-OF-DEFINITION.
    m_tab '006000' '0010' 'J'.
    m_tab '006000' '0010' 'J'.
    m_tab '006000' '0010' 'M'.
    m_tab '006000' '0010' 'M'.
    m_tab '006000' '0010' 'O'.
    m_tab '006000' '0010' 'O'.
    m_tab '006000' '0010' 'T'.
    m_tab '006000' '0010' 'T'.
    LOOP AT itab INTO fs.
      CONCATENATE fs-col1
                  fs-col2
                  fs-col3
             INTO line
    SEPARATED BY ','.
      APPEND line TO itab2.
    ENDLOOP.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                    =
        filename                        = 'C:\filename.txt'
    *   FILETYPE                        = 'ASC'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   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'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    *   WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    *   SHOW_TRANSFER_STATUS            = ABAP_TRUE
    * IMPORTING
    *   FILELENGTH                      =
      TABLES
        data_tab                        = itab2
    *   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.
      WRITE sy-subrc.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Siddarth

  • How to use '|' delimited as seprator in GUI_DOWNLOAD ? Plz suggest me ,,

    how to use '|' delimited as seprator in GUI_DOWNLOAD ? Plz suggest me ,,
    i want the output should be seprated by '|' delimited when i download the file.

    Hi,
    We will pass the seperator to the WRITE_FIELD_SEPARATOR parameter as
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = v_file
    write_field_separator = '|'
    TABLES
    data_tab = itab[] . "Our internal talbe filled with data
    Re: Why Function GUI_DOWNLOAD can create XML file but not a flat file?
    Award points if useful
    Thanks,
    Ravee...

  • Looking for some assistancte in GUI_DOWNLOAD

    Hi there,
    See I have this exercise I have to do here. Basically I have to create a program that will download the contects of SBOOK to my pc. I have to use GUI_DOWNLOAD in this exercise. Also, the user will have to input the path and file name of the file to be downloaded to. I have place appropriate error message on the screen as well but I'm not sure how to do this.Being relatively new to this, I tried looking for some samples and this is what I came up so far.
    REPORT  ZISTANZS_TRNG_EX9C.
    TABLES: SBOOK.
    PARAMETERS: FILEINP(30) DEFAULT 'c:\TEMP\wee.txt' OBLIGATORY.
    DATA: BEGIN OF ITAB OCCURS 100.
          INCLUDE STRUCTURE SBOOK.
    DATA: END OF ITAB.
    CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
             FILENAME            = FILEINP
             FILETYPE            = 'ASC'
             write_field_separator = 'X'
         TABLES
             DATA_TAB            = ITAB
         EXCEPTIONS
             FILE_OPEN_ERROR     = 1
             FILE_WRITE_ERROR    = 2
             OTHERS              = 3.
    Unfortunately, it doesn't work though. It keeps saying that my FILENAME is not the same data type as FILEINP? I'm asking for some assistance in how this can be properly solved? Any help would be appreciated /

    Hi,
    Please refer the code below:
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open
        ENDIF.
      ENDIF.
    Thanks,
    Sriram Ponna.

  • Urgent-Doubt in GUI_DOWNLOAD

    hi friends,
    In downloading data from internal table using GUI_DOWNLOAD i want only one space to be there after each field ...
    is it right to use write_field_seperator = '   '  or write_field_seperator = 'X'.
    i tried with 'X' i get tab delimited with multiple spaces , also tried with '  ' i got output fields with no space

    Hi Gokul,
    the function module GUI_DOWNLOAD is like this....
    <b>CALL FUNCTION 'GUI_DOWNLOAD'</b>
    EXPORTING
    BIN_FILESIZE =
    filename = 'C:\Documents and Settings\msgpool\Desktop\entries.txt'
    FILETYPE = 'ASC'
    APPEND = ' X'
    <b>write_field_separator = '|'</b>
    TABLES
    data_tab = it_final.
    in that function module you give like this means...
    <u>write_field_seperator = 'X'.</u> that indicates the separator in the file is <b><u>TAB</u></b>so you getting more space between fields....
    you want only one space to be there after each field ...so use like this..
    <b>write_field_seperator = 'SPACE'.</b>
    Now also you getting problem in ouput send a mail to my id....
    <u>[email protected]</u>
    *reward for useful answers*
    With Regards,
    Sandeep.

  • Field separator in gui_download

    Hi,
    How to get '|' (pipeline)  separator in FM gui_download?
    We tried passing '|' in the parameter write_separator.
    Still the downloaded file doesn't have this separator.
    Thanks for your time.

    Hi,
    Try this, ihope it may work.
    WRITE_FIELD_SEPARATOR  = ' | '
    regards,
    ravi shankar reddy

  • 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[].

  • Problem in GUI_DOWNLOAD Function.

    Hello Friends.
    I am trying to do is to download data in a file from a  BAPI
    structure and make a flat file with this format and
    then try to upload the same data in different client
    via LSMW.
    What happens is that I get the download of the file
    contents but the spacing of the characters have
    shifted and so when I run the same file in LSMW the
    values of the fields do not appear consistent.
    Ours is a unicode system ecc 6.0 and when i go in
    debugger I see the values in consistent format but
    when it comes to download it changes .
    kindly please suggest something.
    I also tried to write the file directly with open
    dataset for output but in that also I get an error
    regarding encoding.
    CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
      BIN_FILESIZE                    =
            filename                        = i_file
           filetype                        = 'ASC'
           append                          = ' '
           write_field_separator           = ' '
           header                          = '00'
           trunc_trailing_blanks           = ' '
           write_lf                        = 'X'
    TABLES
            data_tab                        = i_data_tab
    I use the most standard settings.
    Kindly suggest how can I  get the required output.
    Thanks in advance.
    Regards,
    Sohail

    Sohail Mansuri wrote:>
    try to use field separator..then spaces will be maintained...
    > CALL FUNCTION 'GUI_DOWNLOAD'
    >       EXPORTING
    > *   BIN_FILESIZE                    =
    >         filename                        = i_file
    >        filetype                        = 'ASC'
    >        append                          = ' '
            write_field_separator       = 'X '
    >        header                          = '00'
    >        trunc_trailing_blanks           = ' '
    >        write_lf                        = 'X'
    > TABLES
    >         data_tab                        = i_data_tab
    >
    > I use the most standard settings.
    > Kindly suggest how can I  get the required output.
    >
    >
    > Thanks in advance.
    > Regards,
    > Sohail

  • GUI_DOWNLOAD and UPLOAD Function Modules?

    Hi All,
    What exactly done by GUI_DOWNLOAD and UPLOAD Function Modules?
    Akshitha.

    What you exactly want know?
    Here is the Sap documentation for both FM:
    FU GUI_UPLOAD
    Short Text
    Upload for Data Provider
    Functionality
    The module loads a file from the PC to the server. Data can be transferred binarily or as text. Numbers and date fields can be interpreted according to the user settings.
    Example
    Binary upload: No conversion or interpretation
                begin of itab,
                      raw(255) type x,
                end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype =  'BIN'
                  filename = 'C:\DOWNLOAD.BIN'
               tables
                 data_tab = itab.
    Text upload
               begin of itab,
                     text(255) type c,
               end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype = 'ASC'
                  filename = 'C:\DOWNLOAD.TXT'
               tables
                 data_tab = itab.
    Parameters
    FILENAME
    FILETYPE
    HAS_FIELD_SEPARATOR
    HEADER_LENGTH
    READ_BY_LINE
    DAT_MODE
    CODEPAGE
    IGNORE_CERR
    REPLACEMENT
    CHECK_BOM
    VIRUS_SCAN_PROFILE
    NO_AUTH_CHECK
    FILELENGTH
    HEADER
    DATA_TAB
    Exceptions
    FILE_OPEN_ERROR
    FILE_READ_ERROR
    NO_BATCH
    GUI_REFUSE_FILETRANSFER
    INVALID_TYPE
    NO_AUTHORITY
    UNKNOWN_ERROR
    BAD_DATA_FORMAT
    HEADER_NOT_ALLOWED
    SEPARATOR_NOT_ALLOWED
    HEADER_TOO_LONG
    UNKNOWN_DP_ERROR
    ACCESS_DENIED
    DP_OUT_OF_MEMORY
    DISK_FULL
    DP_TIMEOUT
    Function Group
    SFES
    FU GUI_DOWNLOAD
    Short Text
    Download an Internal Table to the PC
    Functionality
    Data transfer of an internal table form the server to a file on the PC. The Gui_Download module replaces the obsolete modules Ws_Download and Download. The file dialog of the download module is available in the class Cl_Gui_Frontend_Services.
    Further information
    TYPE-POOLS: ABAP.
    Binary download table
    DATA: BEGIN OF line_bin,
             data(1024) TYPE X,
          END OF line_bin.
    DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
    Ascii download table
    DATA: BEGIN OF line_asc,
             text(1024) TYPE C,
          END OF line_asc.
    DATA: data_tab_asc LIKE STANDARD TABLE OF line_asc.
    DAT download table
    DATA: BEGIN OF line_dat,
             Packed   TYPE P,
             Text(10) TYPE C,
             Number   TYPE I,
             Date     TYPE D,
             Time     TYPE T,
             Float    TYPE F,
             Hex(3)   TYPE X,
             String   TYPE String,
          END OF line_dat.
    DATA: data_tab_dat LIKE STANDARD TABLE OF line_dat.
    Get filename
    DATA: fullpath      TYPE String,
          filename      TYPE String,
          path          TYPE String,
          user_action   TYPE I,
          encoding      TYPE ABAP_ENCODING.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
       EXPORTING
         WINDOW_TITLE         = 'Gui_Download Demo'
         WITH_ENCODING        = 'X'
         INITIAL_DIRECTORY    = 'C:\'
      CHANGING
         FILENAME             = filename
         PATH                 = path
         FULLPATH             = fullpath
         USER_ACTION          = user_action
         FILE_ENCODING        = encoding
      EXCEPTIONS
         CNTL_ERROR           = 1
         ERROR_NO_GUI         = 2
         NOT_SUPPORTED_BY_GUI = 3
         others               = 4.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    IF user_action <> CL_GUI_FRONTEND_SERVICES=>ACTION_OK.
      EXIT.
    ENDIF.
    Download variables
    DATA: length TYPE I.
    Binary download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'BIN'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_bin
       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.
    Ascii download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'ASC'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_asc
       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.
    DAT download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'DAT'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_dat
       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.
    Parameters
    BIN_FILESIZE
    FILENAME
    FILETYPE
    APPEND
    WRITE_FIELD_SEPARATOR
    HEADER
    TRUNC_TRAILING_BLANKS
    WRITE_LF
    COL_SELECT
    COL_SELECT_MASK
    DAT_MODE
    CONFIRM_OVERWRITE
    NO_AUTH_CHECK
    CODEPAGE
    IGNORE_CERR
    REPLACEMENT
    WRITE_BOM
    TRUNC_TRAILING_BLANKS_EOL
    WK1_N_FORMAT
    WK1_N_SIZE
    WK1_T_FORMAT
    WK1_T_SIZE
    WRITE_EOL
    FILELENGTH
    DATA_TAB
    FIELDNAMES
    Exceptions
    FILE_WRITE_ERROR
    NO_BATCH
    GUI_REFUSE_FILETRANSFER
    INVALID_TYPE
    NO_AUTHORITY
    UNKNOWN_ERROR
    HEADER_NOT_ALLOWED
    SEPARATOR_NOT_ALLOWED
    FILESIZE_NOT_ALLOWED
    HEADER_TOO_LONG
    DP_ERROR_CREATE
    DP_ERROR_SEND
    DP_ERROR_WRITE
    UNKNOWN_DP_ERROR
    ACCESS_DENIED
    DP_OUT_OF_MEMORY
    DISK_FULL
    DP_TIMEOUT
    FILE_NOT_FOUND
    DATAPROVIDER_EXCEPTION
    CONTROL_FLUSH_ERROR
    Function Group
    SFES

  • 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.

  • Extra line while downloading xl file via gui_download

    Hi,
    I am download a XL file using the gui_download.
    but one line automaticall coming like
    F1    F2   F3 F4  ....... and so on
    to all the fields..
    Please give any advise how to remove that first line with F1.....and so on..
    Thanks,
    Suresh

    Hi,
    Please chec kthe below FM see the paramenters i m passing
    g_full_path ---> will have the file path
    itab_amex ---> this is my final internal table with headings...
    i m not using fieldnames , because it is not giving full headings..
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                    =
        filename                        = g_full_path
       filetype                        = 'DBF'
      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_amex
       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.

Maybe you are looking for