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

currency conversion issue

Former Member
0 Likes
827

Hi All,

When I am trying to divide BSID-DMBE2 / exchange rate then exact value is not coming as

as bsid-dmbe2 is curr 13 ,2 decimals and exchange rate is type p ,5 decimals ...after divide value is not correct.

Please suggest any solution

thanks

bobby

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
644

Hi,

you can do this by declaring a variable which is of type currency, like

say the Exchange rate is g_exrate of type p,2 decimals,

so declare one more Variable as g_exrate_new type BSID-DMBE2 .

Then Type Convert the Exchange Rate Variable to BSID-DMBE2 .

simply do g_exrate_new = g_exrate.

so g_exrate_new will now be same as Currency Type.

Edited by: Neha Shukla on Nov 14, 2008 2:12 PM

3 REPLIES 3
Read only

Former Member
0 Likes
645

Hi,

you can do this by declaring a variable which is of type currency, like

say the Exchange rate is g_exrate of type p,2 decimals,

so declare one more Variable as g_exrate_new type BSID-DMBE2 .

Then Type Convert the Exchange Rate Variable to BSID-DMBE2 .

simply do g_exrate_new = g_exrate.

so g_exrate_new will now be same as Currency Type.

Edited by: Neha Shukla on Nov 14, 2008 2:12 PM

Read only

Subhankar
Active Contributor
0 Likes
644

Hi...

I also faced same problem when doing the operation in a standard exit.

You just create a Z FM and do the same calculation inside the FM.

My sample code inside the FM look like this...

data : l_rate type ukurs_curr, "Exchange rate

l_rate_type type kurst_curr, "Type of rate

l_l_fact type i, "Local factor

l_f_fact type i. "Foreign factor

  • check local currency ,foreign currency local amount are not initial

check foreign_currency is not initial and

local_currency is not initial and

local_amount is not initial.

  • Calculate exchange rate

if local_currency = 'MXN' and foreign_currency = 'USD'.

l_rate_type = 'MXNT'.

else.

l_rate_type = 'M'.

endif.

*Call FUNCTION module to get exchange rate

call function 'READ_EXCHANGE_RATE'

exporting

date = sy-datum

foreign_currency = local_currency

local_currency = foreign_currency

type_of_rate = l_rate_type

importing

exchange_rate = l_rate

foreign_factor = l_f_fact

local_factor = l_l_fact

exceptions

no_rate_found = 1

no_factors_found = 2

no_spread_found = 3

derived_2_times = 4

overflow = 5

zero_rate = 6

others = 7

.

if sy-subrc eq 0.

if l_rate le 0.

l_rate = l_rate * -1.

endif.

  • Foreign amount

if l_rate_type = 'MXNT'.

foreign_amount = local_amount / l_rate .

else.

foreign_amount = local_amount * l_rate .

endif.

endif.

I think it will solve your problem.

Read only

Former Member
0 Likes
644

Hi

U should use fm CONVERT_TO_LOCAL_CURRENCY or CONVERT_TO_FOREIGN_CURRENCY

Max