2006 Feb 24 10:33 AM
Hi All,
I'm displaying a currency field amount,
In display the field amount is showing as 900,
where as internally when i use the same field for division it's value is being considered as 9.0 & hence getting some wrong values.
Is there any way to over come this.
Regards,
Raghavendra
Hi All,
I'm displaying a currency field amount,
In display the field amount is showing as 900,
where as internally when i use the same field for division it's value is being considered as 9.0 & hence getting some wrong values.
Is there any way to over come this.
Regards,
Raghavendra
2006 Feb 24 10:34 AM
for few countries the database stores the fields which out considering the decimnal amounts.it might be reason.
or otherwise just see that field in debugging before it gets displayed because the code may be in such a way that it removes the decimal point before outputting
2006 Feb 24 10:38 AM
there might problem with system (decimal notation)
check in sytem-->owndata
2006 Feb 24 10:40 AM
While displaying use :
Write : <b>p_amt1 currency p_curr1</b>.
Check this:
data: w_dec1 like tcurx-currdec,
w_amt like ekpo-netwr,
w_rate like tcurr-ukurs,
w_fact1 like tcurr-ffact,
w_fact2 like tcurr-ffact.
parameters:
p_curr1 like tcurc-waers default 'USD',
p_amt1 like ekpo-netwr default '100',
p_curr2 like tcurc-waers default 'JPY',
pdate like sy-datum default sy-datum.
end-of-selection.
write:
/ 'Entered:',
/ ' from currency:', p_amt1 currency p_curr1, p_curr1, '<-', p_amt1,
/ ' to currency :', p_curr2,
/ ' on :', pdate.
CALL FUNCTION 'FWOS_CURRENCY_DECIMALS_READ'
EXPORTING
I_CURRENCY = p_curr1
IMPORTING
E_DECIMALS = w_dec1
EXCEPTIONS
I_CURRENCY_INITIAL = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
w_dec1 = 2.
ENDIF.
p_amt1 = p_amt1 * 10 ** ( w_dec1 - 2 ).
write:
/ 'after adjusting using currency decimals:',
/ ' from currency', p_amt1 currency p_curr1, p_curr1,
'<-', p_amt1, '(', w_dec1, ')'.
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
DATE = pdate
FOREIGN_CURRENCY = p_curr2
LOCAL_AMOUNT = p_amt1
LOCAL_CURRENCY = p_curr1
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE = w_rate
FOREIGN_AMOUNT = w_amt
FOREIGN_FACTOR = w_fact1
LOCAL_FACTOR = w_fact2
* EXCHANGE_RATEX =
* DERIVED_RATE_TYPE =
* FIXED_RATE =
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
write: / 'Conversion to for.curr. failed:',
p_curr1, '->', p_curr2, 'err.code=', sy-subrc.
ELSE.
write: / 'to For.curr:', p_amt1 currency p_curr1, p_curr1, '->',
w_amt currency p_curr2, p_curr2,
'(', w_rate, ')', w_fact1, w_fact2.
ENDIF.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
DATE = pdate
FOREIGN_AMOUNT = p_amt1
FOREIGN_CURRENCY = p_curr1
LOCAL_CURRENCY = p_curr2
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE = w_rate
FOREIGN_FACTOR = w_fact1
LOCAL_AMOUNT = w_amt
LOCAL_FACTOR = w_fact2
* EXCHANGE_RATEX =
* FIXED_RATE =
* DERIVED_RATE_TYPE =
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
write: / 'Conversion to loc.curr. failed:',
p_curr1, '->', p_curr2, 'err.code=', sy-subrc.
ELSE.
write: / 'to Loc.curr:', p_amt1 currency p_curr1, p_curr1, '->',
w_amt currency p_curr2, p_curr2,
'(', w_rate, ')', w_fact1, w_fact2.
ENDIF.
2006 Feb 24 10:58 AM
Hi,
Currencies like JAPANIES, KORIEN there will be no Decimals.
Use you code like this.
Loop at itab.
read table bkpf_it with key
bukrs = itab-bukrs
belnr = itab-belnr
gjahr = itab-gjahr binary search.
write:/ itab-dwrbtr currency bkpf_it-waers,
itab-cwrbtr currency bkpf_it-waers.
endloop.
The above code shows the sample code which will take care of the decimal part along with currencies.
Thanks.
If this helps you reward with points.
If the issue is solved close the thread.
Message was edited by: KDeepak
2006 Feb 24 11:09 AM
Hi All,
I used the bapi, BAPI_CURRENCY_CONV_TO_EXTERNAL to convert from currency format to internal one & later made use of the returned value for calculations & now the problem is solved,
Thanks for all your responses
Regards,
Raghavendra
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |