Application Development 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: 

Download to CSV file

Former Member
0 Kudos

I've an internal table. One of the fields contain text with comas. But when i try downloading the file in CSV format the field is splitted into two fields at the comma position. What could be the solution to this problem. Help me out.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thanks Naimesh. I also tried all the possible options but of no use. Have to search other options. If you have any inputs regarding OLE concepts or material can you please share it with me

9 REPLIES 9

naimesh_patel
Active Contributor
0 Kudos

Hello,

replace , with something like - or ;

or download in .xls or .txt

regards,

Naimesh

Former Member
0 Kudos

Replacing is OK but i want the file to be downloaded in CSV format only. Users requirement

0 Kudos

hi ,

1)use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB as delimiter

2) replacing of deleimter is <b>no</b> data manipulation!

A.

0 Kudos

Hello Phani,

There isn't any way. I have tried with all the options of filetype but I am not able to achieve this....

So, change file type or manipulate data.

regards,

Naimesh

Former Member
0 Kudos

There are other options like using a different delimeter or replace the comma in your field with some other character.

Regards

Anurag

Former Member
0 Kudos

But replacing the ',' with some other field will manipulate the DATA. I don't want that to happen.

I'm helpless in this regard. What to do?

Former Member
0 Kudos

Hi,

In WS_DOWNLOAD function module give the file name as something like 'C:\testing.csv' , filetype as 'DAT' and data_tab as your output internal table eg: itab[].

Remember to declare itab like:

BEGIN OF itab OCCURS 0,

text(3000) TYPE c,

END OF itab.

and store all the values in a single line separated by comma.

Regards

Subbu

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'C:\test.csv'

filetype = 'DAT'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = 'X'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = i_output[]

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 .

Former Member
0 Kudos

Thanks Naimesh. I also tried all the possible options but of no use. Have to search other options. If you have any inputs regarding OLE concepts or material can you please share it with me

0 Kudos

Hello,

Yes you can check report <b>RSDEMO01</b> for OLE for EXCEL. But, the problem remains as it is.

After running this progra, you can see your data in the excel after running this program, but when you save in .csv and again open it, your ',' deliminated got separated.

regards,

Naimesh