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: 

currency conversion - translation rates

Former Member
0 Kudos

Hi,

The amount shall be converted from currency "GBP" to "AUD".

Therefore we have maintained:

- an exchange rate type (which contains "EUR" as the reference currency)

- the translation ratios for the combinations GBP-EUR, EUR-GBP, AUD-EUR, EUR-AUD

- the rates: GBP->EUR, EUR->AUD

Afterwards we used the function module "CONVERT_TO_LOCAL_CURRENCY";

however the result was returncode 3 - meaning "NO_FACTORS_FOUND"

However,if we maintain the translation ratio GBP-AUD,it works.

For me this seems to be not really logic:

The "cross rates" are determined in table tcurr but the "cross ratios" are not.

Is this true or what is/might be the error?

Thanks for your help, Kora

5 REPLIES 5

Former Member
0 Kudos

hi,

check this thread...

Cheers

Alfred

Reward with points for helpful answers.

Former Member
0 Kudos

hi KORA ,

just check this code ,,

hope this gives u some help.

regards,

vijay

-


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 'JPY',

p_amt1 like ekpo-netwr default '7895',

p_curr2 like tcurc-waers default 'SGD',

pdate like sy-datum default '20061011'.

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.

Former Member
0 Kudos

Hi,

check table t006

Regards

amole

Former Member
0 Kudos

Hello,

Thank you for your input so far -

probably I have not expressed myself clearly enough.

The decisive point is that using e.g the function module

'CONVERT_TO_LOCAL_CURRENCY' the system can/does provide 'automatically' cross-rates for the table tcurr (rates) however not for table tcurf (factors).

This has the consequence: if you would like translate e.g. GBP to AUD by using EUR as a reference currency the following entries are necessary:

table tcurr: GBP -> EUR xxx

EUR -> AUD xxx

table tcurf: GBP -> AUD xxx

As the reference currencies are (seemingly) not used in table tcurf for all possible combinations of currencies entries would have to be maintained.

e.g. 120 currencies

table tcurr: Curr X to EUR (120 entries)

EUR to Curr X (120 entries)

= 240 entries

table tcurf: Curr X to Curr Y (120 * 119 entries)

= 14280 entries

Kind regards, Kora

0 Kudos

Kora,

I'm afraid you'll need to maintain all those factors even though the actual rate will be determined using EUR as a reference currency.