Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Download CSV file

former_member188001
Active Participant
0 Likes
2,950

Hi All,

I am using function module SAP_CONVERT_TO_TEX_FORMAT to convert the internal table into CSV file with headings .

Now, when I use the function GUI_DOWNLOAD to download the file, I get a short dump. Please let me know which parameters I am missing.

When I use the parameter data_tab in GUI_DOWNLOAD, I dont get the file with comma seperated and headings. If I remove that parameter, I get a shortdump.

Please see the code below.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
      i_field_seperator          = ','
      i_line_header              = 'X'
      i_filename                 = 'SALES_FORCE.CSV'
    TABLES
      i_tab_sap_data             = gt_output.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'SALES_FORCE.CSV'
    TABLES
      data_tab = gt_output.

Thanks for your help.

Salil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,212

<copy&paste_removed_by_moderator>

Edited by: Julius Bussche on Nov 8, 2009 4:57 PM

=> If you copy&paste again, then your user ID will be drag&dropped...

Hi All,

I am using function module SAP_CONVERT_TO_TEX_FORMAT to convert the internal table into CSV file with headings .

Now, when I use the function GUI_DOWNLOAD to download the file, I get a short dump. Please let me know which parameters I am missing.

When I use the parameter data_tab in GUI_DOWNLOAD, I dont get the file with comma seperated and headings. If I remove that parameter, I get a shortdump.

Please see the code below.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
      i_field_seperator          = ','
      i_line_header              = 'X'
      i_filename                 = 'SALES_FORCE.CSV'
    TABLES
      i_tab_sap_data             = gt_output.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'SALES_FORCE.CSV'
    TABLES
      data_tab = gt_output.

Thanks for your help.

Salil

6 REPLIES 6
Read only

Former Member
0 Likes
1,212

Hi Salil,

What is the dump that you are getting?

Please post the same.

In your FM GUI_download, you need to pass the filename like this.

Hope this code helps. See my next post below....

If that does not fix your issue, please post your dump .

Regards,

SuryaD.

Edited by: SuryaD on Nov 8, 2009 8:26 PM

Edited by: SuryaD on Nov 8, 2009 8:27 PM

Read only

Former Member
0 Likes
1,213

<copy&paste_removed_by_moderator>

Edited by: Julius Bussche on Nov 8, 2009 4:57 PM

=> If you copy&paste again, then your user ID will be drag&dropped...

Read only

0 Likes
1,212

Copy paste from [http://searchsap.techtarget.com/tip/0,289483,sid21_gci1166824,00.html]. Donot copy paste other's work without mentioning the source.

Read only

0 Likes
1,212

Thanks Vikranth. But the file downloaded does not have headings. How do I get the headings.

Read only

0 Likes
1,212

Hello Salil,

If you want to download the internal table in CSV file with the headings, first use SAP_CONVERT_TO_TEX_FORMAT to convert the itab to CSV formatted then use GUI_DOWNLOAD, mentioning the columns headings in a separate internal table and assign it to FIELDNAMES parameter in GUI_DOWNLOAD


TYPE-POOLS: truxs.
DATA: i_data TYPE truxs_t_text_data.
 
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
  EXPORTING
    i_field_seperator          = ','
*   I_LINE_HEADER              =
*   I_FILENAME                 =
*   I_APPL_KEEP                = ' '
  TABLES
    i_tab_sap_data             = itab
 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.
 
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = 'c:\test.csv'
FILETYPE = 'ASC'
IMPORTING
*FILELENGTH = 
TABLES
DATA_TAB = i_data      " internal table containing data
FIELDNAMES = i_column   " internal table containing headers
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6

Vikranth

Read only

0 Likes
1,212

Hi Vikranth,

Thank you so much for all the help.

Regards,

Salil