2008 Jan 28 11:36 AM
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?
2008 Jan 28 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
2008 Jan 28 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
2008 Jan 28 12:46 PM
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
2008 Jan 28 1:04 PM
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
Regards
Ranganath
2008 Jan 28 1:19 PM
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
2008 Jan 31 5:30 AM
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