Skip to Content
author's profile photo Former Member
Former Member

Write Currency statement giving improper results

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jan 28, 2008 at 11:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 11:50 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.