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

Comma decimal notation in CSV file

Former Member
0 Likes
2,965

Hi

I am downloading data into CSV file separated by semi-colon. There are numeric fields with format 12.34

Can you please let me know how to download in format 12,34 (comma notation) in CSV file.

Thanks

Satish

9 REPLIES 9
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,702

Before moving the data to internal table you need to format your value. Use a char type variable. Is this a amount field if yes than you can use write to with currency and quanityt addition.

Nabheet

Read only

0 Likes
1,702

Thank you Nabheet for your quick response.

I have formatted before downloading but here the download is to CSV file. At place of comma the numeric value is broken into 2 parts.

Read only

0 Likes
1,702

add double quotes in each field..(before and after)

like

"abc";"def";"123,00";"56,45"

and then download into "test.CSV", your CSV file.. now when you open the excel it will all be in one column, you can either run a macro or do a text to column with delimiter as semicolon(;)..to split the column..

Now, if keeping semicolon is not mandatory, it will be even easier..

create lines like

"abc","def","123,00","56,45" ==> see i have kept commas for both delimiter as well as decimal separator

but when you download , it will only split the columns based on the delimiter commas not the commas which are inside " "s

Edited by: Soumyaprakash Mishra on Jan 24, 2012 3:46 PM

Read only

0 Likes
1,702

Thank you Soumyaprakash.

I have already done concatenation with quote. But still the the value is divided into 2 columns.

Ex:

CONDENSE wa_salaire_reference-salaire_base_mal.

CONCATENATE '"' wa_salaire_reference-salaire_base_mal '"' INTO wa_salaire_reference-salaire_base_mal.

Read only

0 Likes
1,702

i wrote a very simple code and it worked, let me know what you think of it..

REPORT  ztest.
DATA: s1 type TABLE OF string,
      sw like LINE OF s1.

move '"abcd","10,23","asdasd","10,00"' to sw.
append sw to s1.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                        = 'D:/ABC.CSV'
  tables
    data_tab                        = s1.

Read only

0 Likes
1,702

Soumyaprakash, your piece of code works well for comma separated CSV file but not for semi-colon separated file.

Could you please check.

Read only

JL23
Active Contributor
0 Likes
1,702

from where do you create this CSV file?

Read only

Former Member
0 Likes
1,702

I create the CSV file using GUI_DOWNLOAD with ASC type and .CSV extension.

File is being created successfully. Only problem with numeric fields (made character type in program).

Read only

JL23
Active Contributor
0 Likes
1,702

ASC as file type controls how the data is prepared in the file.

the file extension does not really control anything of the file content.

if you exchange xls with doc, then word opens and tries to interpred the content, but the excel file did not really become a word document just while you change the extension.

So just adding an extension CSV does not make a CSV file fout of an ASC file.

Please have a look into this OSS note, it explains why SAP does not support CSV

Note 1066919 - Showcase GUI_UPLOAD: Comma separated value (CSV) file

contrary in OSS note 1167125 SAP says :

we suggest changing the download format into a CSV file by using the WRITE_FIELD_SEPARATOR = 'X' parameter for calling the GUI_DOWNLOAD and changing the file extension.

Edited by: Jürgen L. on Jan 24, 2012 2:19 PM