FM : SAP_CONVERT_TO_CSV_FORMAT

Hi,
I'm using SAP_CONVERT_TO_CSV_FORMAT function module. What my requirement is I want to put the charactor fields in " " like Material Number, PO Number etc.
Where I can make the change to get the desired output..?
Thanks,
Gaurav

Hi Gaurav,
Check this function module .
SAP_CONVERT_TO_TEX_FORMAT
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
      i_field_seperator    = ','  "separator
    TABLES
      i_tab_sap_data       = it_final "to be converted data
    CHANGING
      i_tab_converted_data = it_first "after conversion
    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.
Thanks & Regards
Himayat

Similar Messages

  • SAP_CONVERT_TO_CSV_FORMAT for more than 2 lakh records

    Hi All,
    I am trying to uploadingfile to application server in .csv format.
    Using this FM SAP_CONVERT_TO_CSV_FORMAT,converting the itab values  to .csv format.Then using open data set i am uploading the file to application server.
    This logic works fine ,if number of records in internal table is very less.
    if size is more i am getting a dump error 'No more storage space available for extending an internal table'.
    Please suggest how to increase the size of this internal table.Please share the code .
    type-pools:truxs
    data:t_conv_data type truxs_t_text_data.
    Regards,
    Niranjan
    Moderator message: very common problem, please search for available information.
    Edited by: Thomas Zloch on Feb 24, 2011 1:04 PM

    Thanks for all your replies.
    Keshu,
    The drawback of using 'ALSM_EXCEL_TO_INTERNAL_TABLE' in more than one stroke is the amount of looping tht needs to be done in order to get data into the my internal table. And my prog is not going to be run in background, so timeout problem is there.
    Sekhar,
    I cannot loop on TEXT_CONVERT_XLS_TO_SAP as this excel is a single file and there is no end row logic in that.
    Karthik,
    I think the new excel file .xlsx format is having the flexibility to put more than 65536 rows.

  • FM SAP_CONVERT_TO_CSV_FORMAT - separator is wrong.

    I am using FM SAP_CONVERT_TO_CSV_FORMAT and I have the field separator as a comma but when the file is exported it has the separator as a semicolon.  Does anybody have any ideas why this is happening?  Below is my code and a portion of the exported document:
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
        EXPORTING
          i_field_seperator    = ','
        TABLES
          i_tab_sap_data       = it_table
        CHANGING
          i_tab_converted_data = it_table_csv
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = w_filename
        TABLES
          data_tab = it_table_csv
        EXCEPTIONS
          OTHERS   = 1.
    0080629699;04/05/2007;LF;04/05/2007;0520;H1;01;PP;Destination;0000200471;DI;0000200471
    Regards,
    Davis

    You can use GUI_DOWNLOAD FM ,for field separator :
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(BIN_FILESIZE) TYPE  I OPTIONAL
    *"     REFERENCE(FILENAME) TYPE  STRING
    *"     REFERENCE(FILETYPE) TYPE  CHAR10 DEFAULT 'ASC'
    *"     REFERENCE(APPEND) TYPE  CHAR01 DEFAULT SPACE
    *"     <b>REFERENCE(WRITE_FIELD_SEPARATOR) TYPE  CHAR01</b> DEFAULT SPACE
    *"     REFERENCE(HEADER) TYPE  XSTRING DEFAULT '00'
    *"     REFERENCE(TRUNC_TRAILING_BLANKS) TYPE  CHAR01 DEFAULT SPACE
    *"     REFERENCE(WRITE_LF) TYPE  CHAR01 DEFAULT 'X'
    *"     REFERENCE(COL_SELECT) TYPE  CHAR01 DEFAULT SPACE
    *"     REFERENCE(COL_SELECT_MASK) TYPE  CHAR255 DEFAULT SPACE
    *"     REFERENCE(DAT_MODE) TYPE  CHAR01 DEFAULT SPACE
    *"  EXPORTING
    *"     VALUE(FILELENGTH) TYPE  I
    *"  TABLES
    *"      DATA_TAB
    *"  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
    Thanks
    Seshu

  • Error using FM SAP_CONVERT_TO_CSV_FORMAT

    Good day everyone.
                    I'm having problems with the FM SAP_CONVERT_TO_CSV_FORMAT and to be honest I don't have the slightest idea why it prompts the run time error DBIF_RSQL_INVALID_RSQL.
    Below is my sample code:
    TYPE-POOLS:TRUXS.
    DATA: ITAB1 TYPE TRUXS_T_TEXT_DATA OCCURS 0.
      SELECT polno lname fname mi pfx apl pos ofccode basic gsisid empno div stn
                   duemon ps psion psint psintion gs gsion gsint gsintion ec ecion ecint  
      FROM zcddepted
      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 <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Hope you guys could help me.  What happens is that when I try to execute the program the run time error automatically comes out.  Below is the reason of the error:
    What happened?                                                                               
    Error in the ABAP Application Program                                                                               
    The current ABAP program "ZCD_DEPTED_LAYOUT" had to be terminated
        because it has come across a statement that unfortunately cannot be
        executed.
    Please, please, please, hope you guys could help me.  Thanks in advance.
    Anna

    Hi,
    Could you please tell me the number of records being fetched by your select statement?
    If they are very large in number,then this short dump occurs.
    Also, try reducing the number of fields being fetched in the Select statement and it might work because sometimes the size of the memory available to hold the data exceeds.
    Also, try using "Into corresponding fields of" instead of into itab. in the Select statement.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • 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

  • Issue while downloading file in .CSV format

    Hi,
    I need to download the file in .CSV format.
    I hade used FM SAP_CONVERT_TO_CSV_FORMAT  and then used GUI_Download.
    Now when I am opening file which is downloaded, it gives all the data in a single column. If there are 5 fields in my table, the generated file gives the data of all the 5 fields in a single column.
    Could you please help?

    Hi try wi th the following code.
    TYPE-POOLS : truxs.
    DATA: t_file TYPE STANDARD TABLE OF type_file.
    data:t_conv_data TYPE truxs_t_text_data.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ', '
      TABLES
        i_tab_sap_data             = t_file
    CHANGING
       i_tab_converted_data       = t_conv_data
    EXCEPTIONS
       conversion_failed          = 1
       OTHERS                     = 2.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                = 'C:\TESTCSV.CSV'
        filetype                = 'ASC'
        write_field_separator   = '  '
      TABLES
        data_tab                = t_file
       fieldnames              = names
      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.

  • Getting error while uploading data  using the EXCEL( GUI_upload)

    Dear Freinds,
    I am uploading data from my excel sheet to my Custom table . I am using the below code
    call function 'GUI_UPLOAD'
    exporting
    filename = l_fn
    filetype = 'BIN' "'ASC'
    has_field_separator = 'X'
    tables
    data_tab = p_i_ins_db
    exceptions
    others = 17.
    i can see in my internal P_i_ins_db ...all the data is coming in encrypted format.
    The flat given to me is the .CSV file .
    Could any one please let me know how i can upload the data which is there in .csv file.
    regards
    syamala

    Hi Syamala,
    Before using the GUI_UPLOAD to upload the data from the excel file to the internal table,you can try usng the Function Module 'SAP_CONVERT_TO_TEX_FORMAT' or 'SAP_CONVERT_TO_CSV_FORMAT' as it helps n formatting the data.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • Function module to convert an internal table to an tab delimited XL file

    hi everyone
    can anyone tell me the name of the function module which can convert the data in the internal table to an Excel file (Tab de-limited).
    vamsi

    Hello Vamsi
    Just in case you need functions for the other way around (e.g. .csv-file -> internal table) SAP provides the following function modules:
    - TEXT_CONVERT_CSV_TO_SAP
    - SAP_CONVERT_TO_CSV_FORMAT
    This function group <b>TRUX </b>contains some more interesting function modules.
    Regards
      Uwe

  • Issue with downloading in CSV Format

    Hi SDN,
    i used the FM's SAP_CONVERT_TO_CSV_FORMAT - to convert 2 CSV Format  and
                            GUI_DOWNLOAD  - to download the data 2 presentation server.
    i'm able 2 open the file in CSV format,but the data is displayed in single column only.
    how 2 display in different columns ?
    for example the ITAB contains empno, empname and designation.
    I want it 2 display as :
       EMPNO      EMPNAME     DESIGNATION
         1                xxxxx              Developer
         2                 yyyy               TL
    with tab delimiter.
    now the values are displaying as:
    EMPNO;EMPNAME;DESIGNATION
    1;xxxx;Developer
    2;yyyy;TL
    pls suggest.
    awaiting ur early response.
    Regards,
    Suman.

    Hi Max,
    the issue is when opening the CSV file.
    all the contents are coming in a single column. for ex.,
                    Col 1                                                 Col2          Col3
    Row1      Heading1,Heading2,Heading3
    Row2      a1,b1,c1
    Row3      a2,b2,c2
    Row4      a3,b3,c3
    I'm not sure whether this format is correct  ?
    what I'm expecting is  like the one below, with a tab delimiter.because after runing the ALV report when I export 2 Excel in CSV format it is displaying like this.
                        Col1                Col2               Col3
    Row1          Heading1      Heading2          Heading3
    Row2             a1                    b1                c1
    Row3             a2                     b2               c2
    Row4             a3                     b3                c3
    Regards,
    Suman.

  • Problem with gui_download

    Hi,
    in my gui_download function I'm passing the 'ASC' value to the parameter filetype but, once I go to the txt file downladed and I try to save it as a csv file I realise that it's of type UTF-8 and not an ASCII type.
    Can anybody tell me why the file downloaded isn't of type ASCII?
    Thanks in advance.
    Regards.

    Hi,
    To save .txt file in .csv format.  Follow the below mentioned ways , Hope will help you to solve .....
    1) There are different ways in creating a CSV file. The RIGHT way is to use the function SAP_CONVERT_TO_CSV_FORMAT. You can just go through the FM. To complete, for every convert fuction there is an equal and opposite convert function,  TEXT_CONVERT_CSV_TO_SAP.
    2) Use this [LINK|How to create .csv file from ABAP report; as well.
    Regards,
    Saravana.S
    Edited by: saravanasap on Jan 27, 2012 5:49 AM

  • Download

    hi all,
    Before download using GUI_DOWNLOAD, im adding a comma between the fields of itab sothat GUI_DOWNLOAD can download use comma as delimiter.  Now the problem is i have an amount field which has commas in it as thousand separator.  So, GUI_DOWNLOAD takes this amount field as more than one field like for eg, 5,000 is downloaded into 2 columns like 5 and 000 as there is a comma in it.
    How to change the delimeter of GUI_DOWNLOAD from comma to anyother, say $?
    Thanks & Regards,
    Vinny

    hi vinny,
    kindly note this.
    Tab (09)
    CONSTANTS: con_tab TYPE x VALUE '09'.
    Carriage return (0D)
    CONSTANTS: con_cr type x value '0D',
    try any of this.
    manipulate ur code exmaple
    Check this code..
    REPORT  ZTESTAA.
    TYPE-POOLS:TRUXS.
    DATA: BEGIN OF ITAB OCCURS 0,
         VBELN
    LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          END OF ITAB.
    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 <> 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.
    rgds
    anver
    if hlped pls mark points

  • Separator problem in CSV file download

    Hi All,
    I am downloading the internal table data in CSV file format using the function modules SAP_CONVERT_TO_CSV_FORMAT  and GUI_DOWNLOAD.
    In the FM SAP_CONVERT_TO_CSV_FORMAT the default value for field separator is ;. But I want comma.
    I am passing comma as a field separator but I am getting ; in my CSV file.
    Please help.
    Thanks in Advance.
    - Neha.

    Hi
    It seems fm SAP_CONVERT_TO_CSV_FORMAT doesn't use the parameter I_FIELD_SEPERATOR, but a the constant C_FIELD_SEPARATOR with value ;
    So u should replace ; with comma after calling that fm or check a SAP note
    Max

  • Program for converting fixed length file to csv

    Hello All,
    My requirement is to write a program which will read a file of fixed length separator (file where fields are separated by their length) from application server and convert to CSV file (fields separated by comma) .
    Please help me with code sample.
    regards
    Santosh

    Hi Santosh,
    SAP_CONVERT_TO_CSV_FORMAT
    Hope the above FM helps you.
    Very usefull thread
    reg:currency and quantity
    Have A Nice Day
    Chaitanya.

  • Export Data To Fixed Length File

    Hello,
    I have a requirement to export a couple of files that need to be in a fixed length format. 
    I've tried opening the dataset and writing the records passing the column that the records should appear:
        WRITE /, field1, 10 field2, etc...
    I've also tried to do it through SAP_CONVERT_TO_CSV_FORMAT and the text version as well.
    Is there a predefined function that will allow me to export as fixed length? 
    Thank you in advance

    Hi Jeff,
    Following is the code to do the same:
    DATA: file TYPE string VALUE `flights.dat`,
          wa   TYPE spfli.
    FIELD-SYMBOLS TYPE x.
    OPEN DATASET file FOR OUTPUT IN BINARY MODE.
    SELECT *
           FROM spfli
           INTO wa.
      ASSIGN wa TO CASTING.
      TRANSFER TO file.
    * TRANSFER LENGTH 200 to file.
    ENDSELECT.
    CLOSE DATASET file.
    Best regards,
    Prashant

  • 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

Maybe you are looking for

  • Error while importing Item MAster Data using DTW

    Hi, when we are importing item master data using items template it is giving error. Error:":connected value 1 was not found " can any one send the oitems template that is working fine wthout any error. Thanks, Neetu

  • Add-on de Crystal Reports para b1 2005A

    Saludos,  necesitaría instalar el addon de crystal reports para sap b1 2005A, pero no encuentro el addon en  "Software Distribution Center". Quería saber como podía obtenerlo,  he visto algunos mensajes  sobre el tema pero referentes a la versión de

  • Desperate, won't boot. Screen shows file folder with question mark??

    I'm out of applecare warranty. My PB G4 won't boot. All I get is a gray screen with a small file folder in the center that has a question mark alternating with a little smiling face. Does this mean that my hard drive is fried and the system can't fin

  • "Track this list in Access" not working

    I have a PC with Microsoft Office *2003*, Access 2003, and Windows XP. We use SharePoint 2010. With this configuration, I am able to create a linked table in Access. I have a laptop with Microsoft Office *2010*, Access 2003, and Windows XP. When I us

  • Customize the WEB ADI Journal Import layout

    Hi , I would like to know from gurus , on how to customize the WEB ADI Journal Import Template, as per the client's requirements. I would like to add a custom validation for a line level reference column (Referenc6 of GL JE Lines) and also for the Ac