Application Development 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: 

Unexpected result in currency conversion.

chris_robertson
Participant
0 Kudos

I'm trying to convert foreign currency to local currency using fm CONVERT_TO_LOCAL_CURRENCY. The results that I'm getting back shift the decimal 5 positions to the right.

EXPORTING

DATE = COMM_STRUCTURE-BILL_DATE

FOREIGN_AMOUNT = COMM_STRUCTURE-COST

FOREIGN_CURRENCY = COMM_STRUCTURE-DOC_CURRCY

LOCAL_CURRENCY = COMM_STRUCTURE-LOC_CURRCY

RATE = COMM_STRUCTURE-EXCHG_RATE

  • TYPE_OF_RATE = 'M'

  • READ_TCURR = 'X'

IMPORTING

  • EXCHANGE_RATE =

  • FOREIGN_FACTOR =

LOCAL_AMOUNT = VALUE

  • LOCAL_FACTOR =

  • 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.

An example would be, COST = 100, EXCHG_RATE = -1.48 return LOCAL_AMOUNT = 6756757.

In a different program I used the fm and didn't pass the RATE but passed the TYPE_OF_RATE = 'M'. That worked as desired. Can anyone see what I'm doing wrong?

Thanks,

Chris

1 ACCEPTED SOLUTION

Former Member
0 Kudos

EXCHG_RATE = -1.48.

You are sending the negative value in the exchange rate.

Try sending 1/1.48 i.e., 0.67567 in the rate.

Hope this helps.

Thanks,

Vamshi

4 REPLIES 4

Former Member
0 Kudos

EXCHG_RATE = -1.48.

You are sending the negative value in the exchange rate.

Try sending 1/1.48 i.e., 0.67567 in the rate.

Hope this helps.

Thanks,

Vamshi

0 Kudos

Inverting the rate and passing .67567 gave the same results.

Instead of passing the customer exchange rate, I 'm passing hte customer exchange rate type and letting the program look up the rate. This seems to be working. Though I'm still confused as to why it did not calculate correctly when passing just the rate.

Thanks for your input.

Chris

former_member186741
Active Contributor
0 Kudos

what have you got in the parameters, particularly FOREIGN_CURRENCY and LOCAL_CURRENCY? It could even be a 'case' issue??

It looks like the fm multiplies the rate by 1mill when not sure which currencies it's dealing with.

Check it out in debug to see why it goes down the path it wants to.

0 Kudos

I've looked at it in debug as suggested.

The line that fills the rate field used in the calculation is:

tratex = rate * 1000000.

The actual calculation of the rate is:

refe = - foreign_amount * 100000000000 * tcurr-tfact * ref1 / ( tratex * ref2 * tcurr-ffact ).

I'm not understanding why the rate is multipled by 1000000 and the amount by 100000000000. This seems to be what is causing the problem.

(FYI - In most cases FOREIGN_CURRENCY = 'CAD' and LOCAL_CURRENCY = 'USD'.)