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

CDS View currency conversion problem

former_member202733
Participant
0 Likes
6,937

Hi guys how are you?

I am writing a set of CDS Views and I am faccing a problem with currency fields.

When I display the results via SE16N, the view works fine and show the values correctlty, but when I export the data into a CSV file and thats is the goal of this development, the field appears with a wrong format.

I'm using this annotation in my currency field

        @Semantics.amount.currencyCode: '_posicion.waerk'
        _posicion.netwr,

In SE16N we can see:

But in excel is not Ok:

Is it normal?, I mean, Have I to do some ABAP workarround to get the right currency format?

Just for clarification pourpuse, Im not working whith a HANA database, Im working with Oracle.

I appreciate any help.

Best regards,

Ronaldo S. Vieira

6 REPLIES 6
Read only

pfefferf
Active Contributor
0 Likes
4,358

Yes, that behavior is normal, because SAP stores amounts always with two decimal places, independent how many decimal places a currency really have, e.g.

EUR: 100.00 -> 100.00
COP: 100.000 -> 1000.00
JPY: 100 -> 1.00

SAP Clients like e.g. SE16N convert the value to the correct presentation format, meaning the decimal separator is correctly shifted.

Doing a simple CSV export does not consider this decimal shift if not implemented. To my knowledge there is no CDS function which does that automatically. You can either check the number of decimals for a currency and do the shift in the CDS view (if you wanna have it there for whatever reason - I would not recommend that) or do the shift in the wrapper which creates the CSV.

Read only

former_member202733
Participant
0 Likes
4,358

I'm sorry guys but I have to clarify something here.

When I said I'm exporting the data into a CSV file, I mean, I'm doing this via an ABAP program and put an file into app server.

If I export into a excel using SE16N it's works too.

best regards,

Ronaldo S. Vieira

Read only

stekoester
Explorer
0 Likes
4,358

Hi Ronaldo,

you started to clarify, that you are using an ABAP-Report for the CSV export, but you haven't finished, because you haven't mentioned how you export to CSV.

If the export works in SE16N then your export logic is faulty.

Greetings
Stephan

Read only

former_member202733
Participant
0 Likes
4,358

stekoester Fair enough. Actualy there is no code to format my currency column, I am usigng RTTI, get the values from a generic structure and put the values into the CSV, I just tought that usign the annotation, or something like that, I could get the value formated, but as florian.pfeffer said, I have to to that in in the wrapper method which creating the CSV..

Best regards.

Ronaldo S. Vieira

Read only

DoanManhQuynh
Active Contributor
0 Likes
4,358

you exported data to excel with your custom code so you need to write the value in right currency to your CSV, system cant decide which decimal field would be currency or not . it would be easier to suggest if you tell us how did you code to download to csv.

Read only

0 Likes
4,358

Thanks, quynh.doanmanh I will implement this in my code, I just thought that with the annotation would be enough.