‎2009 Dec 31 7:12 AM
Hi,
I am downloading the contents of my internal table into csv file by separating the contents with a ',' (comma).
But, the problem is that if the data already has a comma, then the system treats it as a separator and causes a problem.
Please let me know how to avoid this.
Regards.
‎2009 Dec 31 7:46 AM
Hi David,
If it is a .csv file then we cannot have the , (comma) in between the data as it will be always treated as a separator.
‎2009 Dec 31 7:55 AM
Hi David,
U can achieve it in multiple steps. Firstly u need to have a new itab with a string typed variable like this
Step: 1
DATA: BEGIN OF itab OCCURS 0,
document TYPE string,
END OF itab.
Step: 2
move ur comma seperated data into this itab through a loop and for the field which u feel has already a comma in it
write an if statement for it and move ur data in which u already have a comma to the itab without comma seperation.
Step: 3
Download this new itab as ur .csv file
I hope it will work for u
Cheers
‎2009 Dec 31 8:56 AM
Hi,
Isn't there any way to handle a character in the data which is the same as the separator used while downloading data to a file?
Regards.
‎2009 Dec 31 9:28 AM
Hello,
I never use delimiters in text files I always use fixed width.
I know this takes 10 minutes longer to program in the subsystem because you need to define the structure there and is a little bit less flexible but it always works.
Now you have probably already lost more time in finding a work around for the delimiter that is also used in your actual data fields.
Solution -> use fixed width alphanumeric text files.
Wim
‎2009 Dec 31 10:07 AM
Hi,
My user insists on .csv file.
Please let me know if there is any solution.
Regards.
‎2009 Dec 31 5:31 PM
Hi David,
- you may remove all commas or replace with another character
- you may enclose the fields with comma in quotes, like "field, with, comma", like this
field-symbols:
<rec> type any,
<fld> type any.
loop at itab assigning <rec>.
do.
assign component sy-index of structure <rec> to <fld>.
if not sy-subrc = 0.
exit."do loop
endif.
if <fld> ca ','.
concatenate '"' <fld> '"' into <fld>.
endif.
enddo.
endloop.Excel will ignore the field delimiter , if it is enclosed in quotes.
Regards,
Clemens
‎2010 Jan 04 10:15 AM
David, I have compiled rules to make "universal" CSV files (so that anybody in the world can open them using Excel 2003 and 2007) in this [wiki|http://wiki.sdn.sap.com/wiki/display/ABAP/Excelfiles-CSVformat] (hope it's clear enough) where it shows the solution mentioned by Clemens.
It also shows that comma, as field separator, is not universally recognized.