11-12-2007 5:57 AM
Hi Guys,
I am facing a new problem for the past 3 days in my client site. Recently We changed the currency decimals from 2 to 5. but now when I fetch those value from the data base table. I am finding that the decimals are automatically shifted to last two decimals. That is if the value is 153.35624 its displaying as 153356.24. So my calculations are going wrong.
Can Anyone of you sugest any way I can correct this...
Regrads,
Vijay
11-12-2007 6:00 AM
Hi
See this for currency related problems
Currency Conversion:
______________________
Use the function module
CONVERT_TO_LOCAL_CURRENCY
Writing currency amount to string without thousands seperator
This is usefull e.g. i connection with batch input/call transaction.
GI_OUTPUT-WRBTR: Field type Currency with amount
L_AMOUNT_STRING: Field type c with amount
PERFORM AMOUNT_TO_STRING USING GI_OUTPUT-WRBTR
CHANGING L_AMOUNT_STRING.
FORM AMOUNT_TO_STRING USING P_AMOUNT
CHANGING P_AMOUNT_STRING.
DATA L_SEP(1) TYPE C.
PERFORM GET_THOUSAND_SEPERATOR USING L_SEP.
WRITE P_AMOUNT TO P_AMOUNT_STRING.
REPLACE L_SEP WITH ' ' INTO P_AMOUNT_STRING.
CONDENSE P_AMOUNT_STRING NO-GAPS.
WRITE P_AMOUNT_STRING TO P_AMOUNT_STRING RIGHT-JUSTIFIED.
ENDFORM.
FORM GET_THOUSAND_SEPERATOR USING P_SEP.
DATA: L_AMOUNT LIKE BSEG-DMBTR,
L_AMOUNT_STRING(15) TYPE C.
Find 1000 seperator. If decimal seperator = . then
1000 seperator = , else 1000 seperator = .
L_AMOUNT = '1.00'.
WRITE L_AMOUNT TO L_AMOUNT_STRING.
IF L_AMOUNT_STRING CS ','.
P_SEP = '.'.
ELSE.
P_SEP = ','.
ENDIF.
ENDFORM.
Convert amount to/from string
CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
EXPORTING
betrg = 3000
WAERS = 'DKK'
NEW_DECIMAL_SEPARATOR =
NEW_THOUSANDS_SEPARATOR =
IMPORTING
STRING = slam
.
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = slam2
DECIMAL_SEPARATOR = '.'
THOUSANDS_SEPARATOR =
WAERS = 'HUF'
IMPORTING
BETRG = b2
EXCEPTIONS
CONVERT_ERROR = 1
OTHERS = 2
Language depending formatting
To format a currency amount with decimals according to the currency use
WRITE and the CURRENCY option.
Currency keys an d numbers of decimals are defined in table TCURX Decimal
Places in Currencies.
E.G.
Formatting an amount in Kuwatian Dinars:
Dmbtr = 123456.
Write dmbtr currency 'KUD'
123.456
Write dmbtr currency 'USD'
1234.56
Note that the formatting does not depend on the number of decimals in the
number in the program.
Dmbtr = '12.3456'.
Write dmbtr currency 'USD'
1234.56
To format the decimal and thousand sepearators according to the settings for
a specific country,
use the statement SET COUNTRY <country key>
Settings for countries are defined in table T005 Countries.
The country key used in the statement is field LAND1
E.g.
set country 'US'
Regards
Anji
07-03-2008 6:19 AM