Download to PC as CSV file

Hi,
Is it possible to download data to PC as CSV file
using WS_DOWNLOAD function.If it so,
can u explain how do we achieve this.
Thanks,
Seshagiri

Hi seshagiri,
1. We can use GUI_DOWNLOAD
2. But we have to write some extra logic
   to download in CSV format.
3. For this i have an independent FORM
   which will do this.
4. just copy paste in new program.
  (it will download contents of table t001
   in csv format)
5.
REPORT abc.
type-pools : TRUXS.
change your table declaration and file name
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
select * from t001 into table t001.
PERFORM mydownload TABLES t001 USING 'd:\t001.txt' .
INDEPENDENT FORM
FORM mydownload TABLES orgtab
USING filename .
  DATA : newfilename TYPE string.
Data
  data : itab type TRUXS_T_TEXT_DATA.
  CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
  I_FIELD_SEPERATOR          = ';'
  I_LINE_HEADER              =
  I_FILENAME                 =
  I_APPL_KEEP                = ' '
    TABLES
      I_TAB_SAP_DATA             = orgtab
   CHANGING
     I_TAB_CONVERTED_DATA       =  itab
EXCEPTIONS
  CONVERSION_FAILED          = 1
  OTHERS                     = 2
  newfilename = filename.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME = newfilename
    TABLES
      DATA_TAB = itab.
ENDFORM.                    "myupload
regards,
amit m.

Similar Messages

  • Download int table into csv file with each column in separate column in csv

    Hi All,
    I want to download the data in internal table to CSV file. but each column in the table should come as separate column in csv format.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = GD_FILE
          FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
        tables
          DATA_TAB                = I_LINES_NEW
        EXCEPTIONS
          FILE_OPEN_ERROR         = 1
          FILE_READ_ERROR         = 2
          NO_BATCH                = 3
          GUI_REFUSE_FILETRANSFER = 4
          INVALID_TYPE            = 5
          NO_AUTHORITY            = 6
          UNKNOWN_ERROR           = 7
          BAD_DATA_FORMAT         = 8
          HEADER_NOT_ALLOWED      = 9
          SEPARATOR_NOT_ALLOWED   = 10
          HEADER_TOO_LONG         = 11
          UNKNOWN_DP_ERROR        = 12
          ACCESS_DENIED           = 13
          DP_OUT_OF_MEMORY        = 14
          DISK_FULL               = 15
          DP_TIMEOUT              = 16
          OTHERS                  = 17.
      IF SY-SUBRC NE 0.
        WRITE: 'Error ', SY-SUBRC, 'returned from GUI_DOWNLOAD SAP OUTBOUND'.
        SKIP.
      ENDIF.
    with the above values passd , I am getting csv file but all the columns in one column separated by some square symbol.
    How to separate them into different columns.
    Thanks in advance
    rgds,
    Madhuri

    Below example might help you understand on dowloading CSV file:
    TYPE-POOLS: truxs.
    DATA: i_t001 TYPE STANDARD TABLE OF t001,
          i_data TYPE truxs_t_text_data.
    SELECT * FROM t001 INTO TABLE i_t001 UP TO 20 ROWS.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ','
    *   I_LINE_HEADER              =
    *   I_FILENAME                 =
    *   I_APPL_KEEP                = ' '
      TABLES
        i_tab_sap_data             = i_t001
    CHANGING
       i_tab_converted_data       = i_data
    EXCEPTIONS
       conversion_failed          = 1
       OTHERS                     = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    DATA: file TYPE string VALUE 'C:\testing.csv'.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = file
      CHANGING
        data_tab                = i_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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Eswar

  • Uploading/Downloading table to/from *.csv - file

    Hi all.
    First I need to upload this internal table (actually it is a copy of database table) to a file *.csv, and then to be able to download the table back from it.
    All this should be done using field symbols and methods GUI_UPLOAD, GUI_DOWNLOAD from class CL_GUI_FRONTEND_SERVICES.
    *-- STRUCTURE OF INTERNAL TABLE
    TYPES: BEGIN OF in_tab,
            mandt TYPE zng_so_head-mandt,
            so_num TYPE zng_so_head-so_num,          "type numc
            vend_num TYPE zng_so_head-vend_num,      "type numc
            cust_num TYPE zng_so_head-cust_num,      "type numc
            so_date TYPE zng_so_head-so_date,        "type dats
           END OF in_tab.
    *-- INTERNAL TABLE HOLDING LIST DATA
    DATA res_tab TYPE TABLE OF in_tab WITH HEADER LINE.
    START-OF-SELECTION.
    SELECT h~mandt h~so_num h~vend_num h~cust_num h~so_date
    INTO TABLE res_tab FROM zng_so_head AS h.
    thanks all.
    Message was edited by:
            nikolai gurlenia

    Hi,
    I hope following code will solve your problem.
    DATA : it_itab  TYPE TABLE OF string WITH HEADER LINE,
           v_file1  TYPE rlgrap-filename,
           v_file2  TYPE string.
    CALL FUNCTION 'F4_FILENAME'
      IMPORTING
        file_name = v_file1.
    v_file2 = v_file1.
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = v_file2
      CHANGING
        data_tab                = it_itab[]
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    IF it_itab[] IS NOT INITIAL.
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = v_file2
        CHANGING
          data_tab                = it_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
          not_supported_by_gui    = 22
          error_no_gui            = 23
          OTHERS                  = 24.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDIF.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • How to download a report into CSV file format?.

    Hello all,
    I have a requirement like this.
    I have one custom Report. I need to download this report output into CSV format. In the selection screen, i am giving the pathname where report output need to be saved. Please let me know how to do it..
    Thanks in advance....
    Regards
    Ravi

    TYPE-POOLS: truxs.
    TYPES:
      BEGIN OF ty_Line,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
      END OF ty_Line.
      ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
    DATA: itab   TYPE ty_Lines.
    DATA: itab1  TYPE truxs_t_text_data.
    SELECT
      vbeln
      posnr
      UP TO 10 ROWS
      FROM vbap
      INTO TABLE itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        i_field_seperator    = ';'
      TABLES
        i_tab_sap_data       = itab
      CHANGING
        i_tab_converted_data = itab1
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc &lt;&gt; 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:\TEMP\test.txt'
      TABLES
        data_tab = itab1
      EXCEPTIONS
        OTHERS   = 1.
    I found this in the blogs ....reward if it helps

  • Download apple contacts into csv file

    I have read some online forums.  I did find a programmer who has an app to do this.  It is not a trusted source.  How else can I do this?   I have all my security settings set for trusted sources or the app store.
    I need to download my contacts and reupload to another CRM system.  Thoughts?

    You will find a couple of applications for this.
    Export Address Book 1.9.4
    AB2CSV 2.4.2
    You may need to change your security settings to Anywhere temporarily to download them.

  • Download as a CSV file (excel)

    hi all,
    I am trying to download it as a CSV file (local and unix files), but when i get the data in excel , the issue occurs is:
    F1     F2     F3                                        
    OU Code     OU Name     OU Description                                        
    0000010000     0000010000-PG/US/PRIM CARE                                             
    0000010001     0000010001-PG/US/APOTH COMMODIT     APOTHECON COMMODITY                                        
    note: in the first line iam getting as F1,F2 & F3. i dont want these to come, rest all iam getting it perfectly.
    For downloading it i used the below code:
    *&      Form  DOWNLOAD_FILE
          text
    -->  p1        text
    <--  p2        text
    FORM DOWNLOAD_FILE .
    **Add column headers
      clear x_out_prctr.
      x_out_prctr-prctr = 'OU Code'.
      x_out_prctr-ktext = 'OU Name'.
      x_out_prctr-ltext = 'OU Description'.
      x_out_prctr-OUTNAME = 'OU Type Name'.
      x_out_prctr-OTNAME = 'Organization Type Name'.
      x_out_prctr-POUCODE = 'Parent OU'.
      x_out_prctr-STATUS =  'Status'.
      x_out_prctr-OUOUNAME = 'OU Owner'.
      x_out_prctr-OUAUNAME = 'OU Assistant'.
      x_out_prctr-OUCUNAME = 'OU Controller'.
      x_out_prctr-OUMRUNAME = 'OU MSP Rep'.
      Insert x_out_prctr into it_out index 1.
    Insert x_out_prctr into it_out1 index 1.
      clear x_out_prctr.
      IF p_local = c_x.
        perform gui_download.
      elseif p_unix = c_x.
        open dataset p_file for output in text mode encoding non-unicode
            ignoring conversion errors.
        if sy-subrc = 0.
    *-For Profit Center
          loop at it_out into x_out_prctr.
            transfer x_out_prctr to p_file.
            if sy-subrc ne 0.
              write:/ 'Error writing file'(011), p_file.
              stop.
            endif.
          endloop.
        endif.
      Close dataset
        close dataset p_file.
      endif.
    ENDFORM.                    " DOWNLOAD_FILE
    *&      Form  GUI_DOWNLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM GUI_DOWNLOAD .
      DATA : lv_fname TYPE string.
      CLEAR lv_fname.
      lv_fname = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = lv_fname
          FILETYPE                = 'DBF'
        TABLES
          DATA_TAB                = it_out
        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.
    ENDFORM.                    " GUI_DOWNLOAD
    could any one solve my issue ASAP?
    Regards,
    Shalini

    Hi Karthik,
    when i give the file type as ASC it  is not working, The column heading are getting messed up when i use this. the column heading is coming in one text line. but when i changed it to other one...everthing is working fine...but....in the downloaded file in the first line iam getting the F1 ,F2, F3 ..which i dont want it. if i delete this line my problem will be solved.
    my program code is:
                     Includes                                            *
    *--- BMS standard header and footer routines
    INCLUDE zsrepthd.
    *--- ALV Routinesg
    INCLUDE zvsdi_alv_routines_ver3.
    *--- Authorization Check
    INCLUDE z_selection_auth_check.
                     Types Declarations                                  *
    **-Profit Center
    *-For CEPC table
    TYPES: BEGIN OF ty_cepc,
            prctr TYPE prctr,
            datbi TYPE datbi,
           END OF ty_cepc.
    *-For CEPCT table
    TYPES: BEGIN OF ty_cepct,
            prctr TYPE prctr,
            datbi TYPE datbi,
            ktext TYPE ktext,
            ltext TYPE ltext,
           END OF ty_cepct.
    *-Output field name
    TYPES: BEGIN OF ty_output,
            prctr(10) TYPE c,
            ktext(40) TYPE c,
            ltext TYPE ltext,
            OUTNAME(13) TYPE c,
            OTNAME(30) TYPE c,
            POUCODE(13) TYPE c,
            STATUS(8) TYPE c,
            OUOUNAME(17) TYPE c,
            OUAUNAME(30) TYPE c,
            OUCUNAME(30) TYPE c,
            OUMRUNAME(17) TYPE c,
           END OF ty_output.
                     Internal Table Declarations                         *
    DATA:
    *--- Alv parameters
         it_out_alvp TYPE typ_alv_form_params, "for alv parameters
    **--To store prctr for profit center data
         it_profit_prctr type standard table of ty_cepc,
    **--To store text for profit center data
         it_text_prctr type standard table of ty_cepct.
    **--To store output for profit center data
    DATA: BEGIN OF it_out occurs 0,
            prctr(10) TYPE c,
            ktext(40) TYPE c,
            ltext TYPE ltext,
            OUTNAME(13) TYPE c,
            OTNAME(30) TYPE c,
            POUCODE(13) TYPE c,
            STATUS(8) TYPE c,
            OUOUNAME(17) TYPE c,
            OUAUNAME(30) TYPE c,
            OUCUNAME(30) TYPE c,
            OUMRUNAME(17) TYPE c,
           END OF it_out.
                     Work Area Declarations                              *
    DATA: x_profit_prctr type ty_cepc,
          x_text_prctr type ty_cepct,
          x_out_prctr type ty_output,
                     Data Declarations                                   *
          v_prctr TYPE cepc-prctr,
          l_prctr(10) TYPE c,
          l_ktext(40) TYPE c.
                     Constants Declarations                              *
    CONSTANTS: c_0  TYPE char1 VALUE '0',
               c_x  TYPE char1 VALUE 'X'.
                     Selection Screen                                    *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-fr1.
    SELECT-OPTIONS:  s_prctr FOR v_prctr.
    PARAMETERS:      p_date TYPE sy-datum OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-fr2.
    PARAMETERS: p_local RADIOBUTTON GROUP rb1 USER-COMMAND cmd DEFAULT 'X',
                p_unix  RADIOBUTTON GROUP rb1,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK b2.
                     Initialization                                      *
    INITIALIZATION.
                     At Selection Screen                                 *
    AT SELECTION-SCREEN.
                     At Selection value request                          *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      IF p_local = c_x.
    *--- Getting F4 help for Costcenter file
        PERFORM get_filename CHANGING p_file.
      ELSEIF p_unix = c_x.
        MESSAGE i999(zi) WITH 'This fucntion is not available'(i01).
      ENDIF.
                     Start-of-Selection                                  *
    START-OF-SELECTION.
    *--- Check Authorizations for Selection-screen
      PERFORM z_selection_auth_check.
    **-- Get the profit center data from tables CEPC,CEPCT
      PERFORM f_get_profitcenter.
                     End-of-Selection                                    *
    END-OF-SELECTION.
    **-- Download data to final internal table.
      PERFORM data_output.
      IF NOT it_out[] IS INITIAL.
    *--- Fill the structure for calling the ALV form
        PERFORM initialize_alv_params.
    **-- Display ALV Report
        PERFORM setup_and_display_alv_ver2
           USING
            it_out_alvp      "Parameter structure
            it_out[]         "Internal Data table(header table)
            it_out[].        "Dummy table for Hierarchical ALV!!(item table)
    **-- Down load to excel.
        PERFORM download_file .
      ENDIF.
    *&      Form  f_top_of_page
    *This is to write the top of page
    FORM top_of_page.
      DATA:  lt_list TYPE slis_t_listheader,
             lx_list TYPE slis_listheader.
    *--- Title name
      CLEAR lx_list.
      lx_list-typ  = 'S'.
      lx_list-key  = 'Title name'(t13).
      lx_list-info = sy-title.
      APPEND lx_list TO lt_list.
      IF NOT lt_list IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            it_list_commentary = lt_list.
      ENDIF.
    ENDFORM.                    "top_of_page
    *&      Form  init_page_head
    Description : This subroutine initializes the fields in table BHDGD  *
                  for printing the report heading.                       *
    FORM init_page_head.
      bhdgd-line1  = 'Profit Center Extraction'(h04).
      bhdgd-line2  = sy-title.
      bhdgd-lines  = sy-linsz.
      bhdgd-fcpyrt = sy-uline.
      bhdgd-inifl  = '0'.
    ENDFORM.                    "init_page_head
    *&      Form  initialize_alv_params
    Description : Form to initialize ALV Params
    FORM initialize_alv_params.
      CONSTANTS: lc_alv_grid  TYPE char1 VALUE 'G',  "Grid
                 lc_u         TYPE char1 VALUE 'U'.
      MOVE 'IT_OUT' TO  it_out_alvp-tablname.   "final TABLE
      MOVE sy-repid    TO   it_out_alvp-repid.
      MOVE lc_alv_grid TO   it_out_alvp-alvtype.
      MOVE c_x         TO   it_out_alvp-bringdefaultvar.
      MOVE lc_u        TO   it_out_alvp-variantsavetype.
    ENDFORM.                    " initialize_alv_params
          FORM it_out_init_events                                       *
    -->this is form is to modify the events
    FORM it_out_init_events
          CHANGING
           alevnts TYPE slis_t_event.
      FIELD-SYMBOLS <alevnt> TYPE slis_alv_event.
      LOOP AT alevnts ASSIGNING <alevnt>.
        CASE <alevnt>-name.
          WHEN  slis_ev_top_of_page.
            MOVE 'TOP_OF_PAGE'  TO <alevnt>-form.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    "it_out_init_events
    *&      Form  get_filename
    Description : This subroutine is used for F4 Prompting
    FORM get_filename CHANGING p_path LIKE rlgrap-filename.
      DATA : l_file  LIKE ibipparms-path, "Local file for upload/download
             l_repid LIKE syst-cprog,     "ABAP program, caller in external
                                          "procedures
             l_dynnr TYPE syst-dynnr.     "Current screen No
      l_repid = syst-cprog.
      l_dynnr = syst-dynnr.
    *--- Function module used for F4 help
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = l_repid
          dynpro_number = l_dynnr
        IMPORTING
          file_name     = l_file.
      MOVE l_file TO p_path.
    ENDFORM.                    " get_filename
    *&      Form  F_GET_PROFITCENTER
    *Get the profit center data from CEPC,CEPCT
    FORM f_get_profitcenter.
      SELECT prctr
             datbi
             from cepc
             into table it_profit_prctr
             where prctr in s_prctr
             and   datbi >= p_date.
      IF sy-subrc = c_0.
        SORT it_profit_prctr BY prctr datbi.
      ENDIF.
      If not it_profit_prctr is initial.
        SELECT prctr
               datbi
               ktext
               ltext
               from cepct
               into table it_text_prctr
               for all entries in it_profit_prctr
               where prctr = it_profit_prctr-prctr
               and   datbi = it_profit_prctr-datbi.
        IF sy-subrc = c_0.
          SORT it_text_prctr BY prctr datbi ktext ltext.
        ENDIF.
      endif.
    ENDFORM.                    " F_GET_PROFITCENTER
    *&      Form  DATA_OUTPUT
          text
    -->  p1        text
    <--  p2        text
    FORM DATA_OUTPUT .
      loop at it_profit_prctr into x_profit_prctr.
        read table it_text_prctr into x_text_prctr with key prctr =
                                                x_profit_prctr-prctr
                                                            datbi =
                                                x_profit_prctr-datbi.
        if sy-subrc = 0.
          x_out_prctr-prctr = x_text_prctr-prctr.
          concatenate x_text_prctr-prctr x_text_prctr-ktext into l_ktext
           separated by '-'.
          x_out_prctr-ktext = l_ktext.
          x_out_prctr-ltext = x_text_prctr-ltext.
          x_out_prctr-outname = 'Profit Center'.
          x_out_prctr-status = 'Active'.
        endif.
        append x_out_prctr to it_out.
      endloop.
    ENDFORM.                    " DATA_OUTPUT
    *&      Form  DOWNLOAD_FILE
          text
    -->  p1        text
    <--  p2        text
    FORM DOWNLOAD_FILE .
    **Add column headers
      clear x_out_prctr.
      x_out_prctr-prctr = 'OU Code'.
      x_out_prctr-ktext = 'OU Name'.
      x_out_prctr-ltext = 'OU Description'.
      x_out_prctr-OUTNAME = 'OU Type Name'.
      x_out_prctr-OTNAME = 'Organization Type Name'.
      x_out_prctr-POUCODE = 'Parent OU'.
      x_out_prctr-STATUS =  'Status'.
      x_out_prctr-OUOUNAME = 'OU Owner'.
      x_out_prctr-OUAUNAME = 'OU Assistant'.
      x_out_prctr-OUCUNAME = 'OU Controller'.
      x_out_prctr-OUMRUNAME = 'OU MSP Rep'.
      Insert x_out_prctr into it_out index 1.
    Insert x_out_prctr into it_out1 index 1.
      clear x_out_prctr.
      IF p_local = c_x.
        perform gui_download.
      elseif p_unix = c_x.
        open dataset p_file for output in text mode encoding non-unicode
            ignoring conversion errors.
        if sy-subrc = 0.
    *-For Profit Center
          loop at it_out into x_out_prctr.
            transfer x_out_prctr to p_file.
            if sy-subrc ne 0.
              write:/ 'Error writing file'(011), p_file.
              stop.
            endif.
          endloop.
        endif.
      Close dataset
        close dataset p_file.
      endif.
    ENDFORM.                    " DOWNLOAD_FILE
    *&      Form  GUI_DOWNLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM GUI_DOWNLOAD .
      DATA : lv_fname TYPE string.
      CLEAR lv_fname.
      lv_fname = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = lv_fname
          FILETYPE                = 'DBF'
        TABLES
          DATA_TAB                = it_out
        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.
    ENDFORM.                    " GUI_DOWNLOAD
          FORM it_out_alv_fieldcat_before                               *
    -->  PT_FCAT                                                       *
    -->  ALVP                                                          *
    FORM it_out_alv_fieldcat_before  CHANGING
        pt_fcat TYPE slis_t_fieldcat_alv
        alvp TYPE typ_alv_form_params.
      DATA: lx_fcat TYPE slis_fieldcat_alv.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'PRCTR'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Code'(010).
      lx_fcat-seltext_m      = 'OU Code'(010).
      lx_fcat-seltext_s      = 'OU Code'(010).
      lx_fcat-reptext_ddic   = 'OU Code'(010).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'KTEXT'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Name'(030).
      lx_fcat-seltext_m      = 'OU Name'(030).
      lx_fcat-seltext_s      = 'OU Name'(030).
      lx_fcat-reptext_ddic   = 'OU Name'(030).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'LTEXT'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Description'(040).
      lx_fcat-seltext_m      = 'OU Description'(040).
      lx_fcat-seltext_s      = 'OU Description'(040).
      lx_fcat-reptext_ddic   = 'OU Description'(040).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OUTNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Type Name'(013).
      lx_fcat-seltext_m      = 'OU Type Name'(013).
      lx_fcat-seltext_s      = 'OU Type Name'(013).
      lx_fcat-reptext_ddic   = 'OU Type Name'(013).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OTNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'Organization Type Name'(030).
      lx_fcat-seltext_m      = 'Organization Type Name'(030).
      lx_fcat-seltext_s      = 'Organization Type Name'(030).
      lx_fcat-reptext_ddic   = 'Organization Type Name'(030).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'POUCODE'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'Parent OU Code'(013).
      lx_fcat-seltext_m      = 'Parent OU Code'(013).
      lx_fcat-seltext_s      = 'Parent OU Code'(013).
      lx_fcat-reptext_ddic   = 'Parent OU Code'(013).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'STATUS'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'Status'(008).
      lx_fcat-seltext_m      = 'Status'(008).
      lx_fcat-seltext_s      = 'Status'(008).
      lx_fcat-reptext_ddic   = 'Status'(008).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OUOUNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Owner User Name'(017).
      lx_fcat-seltext_m      = 'OU Owner User Name'(017).
      lx_fcat-seltext_s      = 'OU Owner User Name'(017).
      lx_fcat-reptext_ddic   = 'OU Owner User Name'(017).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OUAUNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Assistant User Name'(030).
      lx_fcat-seltext_m      = 'OU Assistant User Name'(030).
      lx_fcat-seltext_s      = 'OU Assistant User Name'(030).
      lx_fcat-reptext_ddic   = 'OU Assistant User Name'(030).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OUCUNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU Controller User Name'(030).
      lx_fcat-seltext_m      = 'OU Controller User Name'(030).
      lx_fcat-seltext_s      = 'OU Controller User Name'(030).
      lx_fcat-reptext_ddic   = 'OU Controller User Name'(030).
      APPEND lx_fcat TO pt_fcat.
      CLEAR lx_fcat.
      lx_fcat-tabname        = 'IT_OUT'.
      lx_fcat-fieldname      = 'OUMRUNAME'.
      lx_fcat-col_pos        = '1'.
      lx_fcat-ddictxt        = 'M'.
      lx_fcat-seltext_l      = 'OU MSP Rep User Name'(017).
      lx_fcat-seltext_m      = 'OU MSP Rep User Name'(017).
      lx_fcat-seltext_s      = 'OU MSP Rep User Name'(017).
      lx_fcat-reptext_ddic   = 'OU MSP Rep User Name'(017).
      APPEND lx_fcat TO pt_fcat.
    ENDFORM.                    " it_out_alv_fieldcat_before
    Thanks & Regards,
    Shalini

  • Download as a CSV file

    hi all,
        I have created a ALV ,  and i am trying to download it as a CSV file , but when i got the file , the issue occurs:
    as you know , the columns in CSV file is seperate by ' , '  , but one of my column is currency , the value is ' 123.456,789 ' for example .
    so this column must be seperated because it contains ' , '. Is there a way to solve this ? how should i show ' , ' in CSV file ?
    kind regards
    Kevin

    Hi Kevin,
    If you are using the standard ALV export file routines the currency should already be handled.
    If you are coding this yourself then any number field that has a ',' needs to be surrounded by double quotes.
    For example
    999,999.99 needs to be output as "999,999.99",
    Excel treats the double quotes as part of the field delimiter and removes them.
    cheers
    David Cooper

  • Sql query to downloaded csv file

    Hi.
    This is probably something really easy, but I cant find how to do it.
    I want to run a dynamic SQL query and have the output appear in csv format as a file the user can save to disk.
    Is this easy, if so how? Or is there a longer packaged based solution to this?
    Regards,
    Asim

    Asim,
    First you need to create a report, you can use a simple SQL query based report, or if your query is dynamic, use a region of type PL/SQL function returning SQL query. Then go to the reports attributes page and enable the CSV link for that report. When running your report page, you’ll notice a CSV export link that lets your download your report as a CSV file.
    Alternatively, If you don’t want to run the report as a regular HTML DB page at all, then you could just choose the CSV template as the report template on the reports attributes page. When running the page with that template, it opens a file download dialog for the CSV file right away. You could integrate this with your own application by placing a “download” button on some other page, that on clicking of this button branches to the CSV download page and by doing so, lets you download the file.
    Marc

  • Issue when download CSV file

    hi all ,
    i have created a ALV report . and one of the column is 010 for example  ,when i download it as a CSV file , i found this field is shown as 10 instead of 010 .
    Is there a way to solve this ?
    best regards
    Kevin

    Hi,
    you can control the outputs in Spread sheets with the help of Excel control statement like replace etc throug ABAP program itself....
    ex: in XLS sheets you will get  00001 as 1.
        but in xls sheet if you put ' 00001 you will get output as 00001without depleting zero's.
    same we are applying through ABAP statement.
    so, for the final Itab field(which ever) you want to retain 00001 use the mentioned statements in my earlier post.
    Hope i am clear with my explanation. If you are in Doubt still get back to me..

  • How to download "Account" and "Contact" into CSV files

    I need write a program to download table "Account" and "Contact" into files. I am using visual studio 2005, program can be in C# or VB. Any good sample code or reference? Your help will be highly appreciated.

    Hi Jaya,
    I know it has been a long time since this was posted, but may I have the code for downloading accounts to a csv file please?
    [email protected]
    Thanks
    Gaurav

  • Date format in CSV file

    Hello,
    I am working on loading program which downloads the application server CSV file to internal table.
    In the CSV file there is a field date in the format (22/05/2008). When I move this to my internal table field date, it is truncating to '22/05/20'. How to solve this issue.
    Can I load into internal table with the same format?
    Please help me.
    Thanks,
    Shreekant

    Hi, Rangrej
    As all Suggested assign first this date to char type filed length 10 and using following way you can assign this to type date.
    Test Sample Code Bellow.
    TYPES: BEGIN OF ty_test,
      cdate(10),
      date LIKE sy-datum,
      END OF ty_test.
    DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    it_test-cdate = '22/05/2008'. APPEND it_test.
    it_test-cdate = '23/05/2008'. APPEND it_test.
    it_test-cdate = '24/05/2008'. APPEND it_test.
    it_test-cdate = '25/05/2008'. APPEND it_test.
    it_test-cdate = '26/05/2008'. APPEND it_test.
    LOOP AT it_test.
      it_test-date+0(4) = it_test-cdate+6(4).
      it_test-date+4(2) = it_test-cdate+3(2).
      it_test-date+6(2) = it_test-cdate+0(2).
      MODIFY it_test INDEX sy-tabix.
    ENDLOOP.
    Best Regards,
    Faisal

  • Need help to download csv file in application by writting to outputstream.

    HI All,
    Requirment of my client is donloading CSV file from portal.
    My approach  is:
    On clicking "Download" button in JSP I am calling an action in controller and from here I am redirecting call to DownloadCSV.jsp where i am writing to output stream of response.
    Action called in controller:
         @Jpf.Action(forwards = { @Jpf.Forward(name = StaticConstants.SUCCESS, redirect = true, path = "DownloadCSV.jsp") })
         public Forward gotoReports() {
              Forward forward = new Forward(StaticConstants.SUCCESS);
              return forward;
    Download jsp:
    response.resetBuffer();
         response.reset();
         response.setContentType("application/vnd.ms-excel");
         response.addHeader("Content-Disposition", "attachment;filename="+ companyId +"_Audit_Report.csv");
         ServletOutputStream os = response.getOutputStream();
              os .println();
              os .print("DATE");
              os .print("USER");
    os .println();
    os.flush();
    os.close();
    I am able to download the csv file in excel. But after that i am not able to perform any operation in portal page. Mouser pointer becomes busy and cant click on anything.
    Second approach followed:
    I wrote the code for writting to outputstream of outputresponse in controller action itself and forwarded to the same jsp where my download button resides.
    Problem:
    Download happens perfectly but the excel in csv format contains the portal framework generated content also other than content i wrote to response.
    If u have any other approach to download an excel without redirecting to JSP plz let me know. Coing is being done in 10.2 weblogic portal.
    Please help. Its very urgent.
    Plz let me know how a file can be downloded in portal context without keeping a file at server side. I need to download file by writting to outputstream.
    If it is possible plz attach one small example project also.
    Thanks a ton in advance.
    It is very important plz do reply.

    Hi Srinivas,
    For downloading binary content that is not text/html, the Oracle WebLogic Portal content management tools use javascript in an onclick event handler to set the window URL to the URL of a download pageflow controller: window.location = url. The content management tools are in a portal so it should be possible for you to do the same thing.
    The url is a custom pageflow controller that streams the bytes to the response. It sounds like you already have a pageflow you could recycle to use in that way. You don't want to stay within your portlet pageflow because then you will be streaming bytes into the middle of a portal response. You want a separate download pageflow that you invoke directly, outside of the portal framework (in other words, don't invoke it by rendering a portlet that invokes the pageflow).
    You can set the url to invoke the pageflow directly by giving the path to the pageflow controller from the web root (remember the pageflow path matches the package name of the pageflow controller class) like this: "/content/node/nodeSelected/download/DownloadContentController.jpf"
    By the way, for the case of text/html, the tools uses a standalone portlet URL so that the text/html is not rendered in the browser window, which would replace the portal markup (because the browser renders text/html by default, instead of giving you a download widget or opening some other application to deal with the bytes).

  • Download CSV-File from Interactive Report

    Dear all,
    I want to download a CSV-File from a Interactive report.
    The content of the Rows in Excel:
    Erste,"B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"
    IBC ->,"-","1","2","3","4","5","6","7","8","9","10","11","12","13","14" [...]
    How can I solve this problem?
    Thanks for help.

    Your CSV-File use "comma" as separator. But Excel think, that CSV-File separator is "semicolon".
    Try to set "CSV Separator"=";" in section "Report Attributes" - "Download".

  • Problem with finding correct application to open a .csv file from Downloads

    Hi Guys. I've been a Mac user for some time now but have only just found this forum! Anyway, I've downloaded a .csv file to my Download folder but when I click on it to open it I get the "Can't find an application etc. " message. When the dropdown "Choose Application" menu appears it wont choose (ie the "Open" button won't enable). What is a .csv file and what Application would open it (if I can get the thing to choose one in the first place?)
    Your help would be greatly appreciated. (BTW the file comes from my Paypal history if that helps.)

    A .csv file is a standard text file which typically contains data of some sort.
    CSV stands for Comma Separated Values.
    You could open the file using TextEdit, or a Word processor... but the content of the file might look a little strange and it won't be easy to read.
    Your best bet is to import this .csv file using a Spreadsheet application such as Microsoft Excel or other.

  • How to get fixed field length when download a CSV  file ?

    hi all ,
        I had downloaded a CSV file from an ALV list which created by myself. the current layout of the CSV file is :
    aaa;bbbbbbbbbb;cc;                
                                                         for example . but what i want is :
    aaa         ;bbbbbbbbbbb            ;cc     ; 
    it means these three fields are all with fixed length don't ommitting spaces when you preview the CSV file. how should i do this ?
    best regards
    Kevin

    i got the solution.

Maybe you are looking for

  • Update Not Working

    So I have tried everything to get the 4.3 update to work on my Galaxy S4. I even factory reset the entire phone, deleting absolutely everything, and the update STILL doesn't work. It takes forever to download, then it verifies the download, then it s

  • How to find out the image size?

    How to find out the image size values(Width and height) in illustrator CS3 using any script. I tried but i got only the document height and width. I need to find out the image BoundingBox value of width and height. Kindly advice me.

  • SAP in a Oracle server

    Is it possible to apply and use a SAP as a layer on a Oracle Database. Should the DBA have the knowledge on SAP to perform this... ?

  • I've been getting Kernal Panic!!! pls Help!

    Alright so i had kernal panic before.. not sure if it's the same problem but i took a look at the problem and i got this: Any Ideas? Wed Apr 8 15:08:16 2009 panic(cpu 1 caller 0x001A936C): Double fault at 0x620ba863, thread:0xb2485d0, trapno:0x8, err

  • Disc Stuck in Intel iMac... STILL After Trying Literally EVERYTHING!

    It's been almost a month now and I still have a standard CD-R stuck in my disk drive. While my iMac is still useable, the disk drive cycles and taunts me every 4-5 seconds as it attempts to once again eject the disk. The battle has been fierce and I