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

Write Currency statement giving improper results

Former Member
0 Likes
4,604

Hi,

I am using the Write <number > Currency < currenty unit> To <text variable> statement to format an amount as the currency unit decimal places. But its not giving proper result.

The Code is:

-


WRITE y_v_camount TO y_v_camnt CURRENCY y_lv_waerk.

-


Here the value of

Y_V_CAMOUNT is 8124.00

Y_LV_WAERK has value 'HUF'

& after write statement is executed the value in

Y_V_CAMNT is 812.400

Currency HUF has 0 decimals defined in table TCRUX. Hence the value of Y_V_CAMNT should have been just 8124 & not 812.400.

The data type for

Y_V_CAMOUNT is NETPR

Y_V_CAMNT is TEXT25 &

Y_LV_WAERK is WAERK

Can anybody point out what could be the possible problem?

Hi,

I am using the Write <number > Currency < currenty unit> To <text variable> statement to format an amount as the currency unit decimal places. But its not giving proper result.

The Code is:

-


WRITE y_v_camount TO y_v_camnt CURRENCY y_lv_waerk.

-


Here the value of

Y_V_CAMOUNT is 8124.00

Y_LV_WAERK has value 'HUF'

& after write statement is executed the value in

Y_V_CAMNT is 812.400

Currency HUF has 0 decimals defined in table TCRUX. Hence the value of Y_V_CAMNT should have been just 8124 & not 812.400.

The data type for

Y_V_CAMOUNT is NETPR

Y_V_CAMNT is TEXT25 &

Y_LV_WAERK is WAERK

Can anybody point out what could be the possible problem?

6 REPLIES 6
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,855

hi Pramod,

SAP is right, the value is 812.400. If you see 8124.00 in the database and there are no decimals to the currency, than it has to be multiplied with 100 (i. e. the decimal places are also used for storing the integer part of the number).

hope this helps

ec

Read only

Former Member
0 Likes
1,855

Hi Pramod

When you are using the decimal values to be printed based on TCURX table SAP recommends to use the type P fields without any decimals. Please refer the link below for more details, that should throw more light to your problem

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba1ef35c111d1829f0000e829fbfe/content.htm

Regards

Ranganath

Read only

0 Likes
1,855

Hi Ranganath,

Thanks for the reply.

I changed the data type of

Y_V_CAMOUNT to p from netpr

The value in Y_V_CAMOUNT after the change is 8124

but the value in

Y_V_CAMNT after the write the statement is executed is 8.124

It should have been 8124 as currency HUF is defined with zero decimals in TCURX.

Can't figure out why !

Regards

Read only

0 Likes
1,855

Hi Pramod

I read few articles and it mentioned we have factor it by 100 when it is maintained as 0 decimals in TCURX table. You can once again check this thread for more details

http://sap.ittoolbox.com/groups/technical-functional/sap-bw/key-figure-in-cube-is-multiplied-by-100-...

Regards

Ranganath

Read only

0 Likes
1,855

Hi there,

Here is some example ABAP code which converts a value from how it is stored in SAP to how it should be displayed to the user using the function module 'CURRENCY_AMOUNT_DISPLAY_TO_SAP' .

[Convert currency value from SAP to display|http://www.sapdev.co.uk/fmodules/curr_saptodis.htm]

and vice versa

[Convert currency value from display to SAP|http://www.sapdev.co.uk/fmodules/curr_distosap.htm]

Regards

MArt

Read only

0 Likes
1,855

Hi Mart,

Thanks for providing the link.

The problem was that the program was reading the amt value from a flat file (which was already in a correct format) & not a SAP Table.

Had the value been read from an SAP Table, the value in the variable Y_V_CAMOUNT would have been 81.24 HUF & after using the WRITE CURRENCY logic Y_V_CAMNT would have 8124.

I used 'CURRENCY_AMOUNT_DISPLAY_TO_SAP' by passing & changing Y_V_CAMOUNT before the Write statement (with some additional logic) & got the right result.

Regards,

Pramod