Skip to Content
0

Change decimal point to a commain CSV output

Sep 07, 2017 at 09:26 PM

151

avatar image

Hi all,

I have an internal table that I use for creating an ALV and also creating a .CSV table using the FM SAP_CONVERT_TO_CSV_FORMAT . So far, so good. My problem begins when one of the itab’s columns is a negative number. In that case, the sign appears to the right of the number, which is something that Excel does not like.

Lo and behold, I created a char column with the proper sign position using the FM 'CLOI_PUT_SIGN_IN_FRONT'. Now my problem is that the column’s decimal separator goes from a comma (,) (the standard in my country) to a point (.)All the other numerical columns seem to be ok (they appear with a decimal comma).

Any ideas how to fix this (short of using REPLACE, which seems to me a very kludgy workaround)?

Thanks in advance,

Luis

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Horst Keller
Sep 08, 2017 at 03:15 PM
0

FM 'CLOI_PUT_SIGN_IN_FRONT' ?????

Format options in string templates!

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Horst,

Thanks for your answer.

Yes, I had tried using the CLOI_PUT_SIGN_IN_FRONT FM. And yes, it works but, for reasons unknown to me, it converts my country's decimal separator (a comma) to a point.

As I wrote before, it is interesting to note that using the 'SAP_CONVERT_TO_XLS_FORMAT' FM everything works correctly (signs, commas, etc). Using the 'SAP_CONVERT_TO_CSV_FORMAT' FM the conversion is not as good.

Although I prefer the CSV format simpler output, I think that for the time being I will use the CONVERT_TO_XLS option.

Thanks again,

Luis

0

What I mean is, why use clumsy function modules if there are powerful built-in formatting features in the language itself ...

0

That's an excellent point. Maybe I will give it a shot.

Thanks again,

Luis

0
Nic Teunckens Sep 08, 2017 at 06:57 AM
0

Can you see a change after modifying your settings as mentioned in this Blog : link ...

That could be an easy workaround, without additional coding ...

Check SAP ONE Support Launchpad, there are numerous KBA's on ALV / Excel and handling Currency / Quentity / Decimals ...

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Nic,

Thanks for your post. My PC's settings (and Excel's) are all ok. The main point here is that I'm not converting to .XLS. I'm converting to .CSV and, AFAIK, the "SAP_CONVERT_TO_CSV_FORMAT" FM does not use (or need) any of those settings.

*Maybe* I will convert the itab to a proper Excel file. It was something that I was avoiding due to the fact that the conversion is somewhat (a lot!!) slower. We'll see.

Thanks again,

Luis

0

One work around (not the neatest, I believe, in terms of code) would be convertig to a char value with WRITE..USING and an EDIT MASK.

What I find interesting is that if you convert your ALV to excel (which in fact is a CSV file) using SAP's export option (as opposed to using the FM) , this does not happens....

Regards,

Luis

0