‎2008 Apr 16 2:06 AM
Hi
I tried the following FM to convert Currency, Sy-Subrc = 0.
pls advise me if i am wrong
LOOP AT IT_DETAIL.
If s_waers is not initial.
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_CURRENCY = s_WAERS
LOCAL_AMOUNT = it_detail-dmbtr
LOCAL_CURRENCY = bkpf-waers
rate = 0
TYPE_OF_RATE = 'M'
IMPORTING
exchange_rate =
FOREIGN_AMOUNT = it_detail-dmbtr
foreign_factor =
local_factor =
exchange_ratex =
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
OTHERS = 4.
if sy-subrc<> 0
ELSE.
ENDIF.
ENDLOOP.
‎2008 Apr 16 4:18 AM
Hi Kumar,
Have a look the following .
Regards,
Venkat.O
LOOP AT it_detail.
IF s_waers[] IS NOT INITIAL.
"Select-Option s_waers is a internal table
"You cant pass s_waers as a variable, as foreign_currency in CONVERT_TO_FOREIGN_CURRENCY function module.
"What you have to do is read the table s_waers for perticalular currency and pass through function module
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
date = sy-datum
foreign_currency = s_waers " You cant pass like this as s_waers is internal table.
local_amount = it_detail-dmbtr
local_currency = bkpf-waers
type_of_rate = 'M'
IMPORTING
foreign_amount = it_detail-dmbtr.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDLOOP.
‎2008 Apr 16 3:12 AM
Hi,
How is the currency key input field (s_WAERS) defined?
It should be char field with value of currency code in it (eg USD).
If it is select option as the name implies the code will not work.
‎2008 Apr 16 3:28 AM
Hi Sudhir
s_waers defined as ,
SELECT-OPTIONS: s_waers FOR bkpf-waers.
‎2008 Apr 16 3:32 AM
Hi,
You have to define a new variable of char type and pass currency code to it. Then use this as input value to currency code parameter of the FM.
You cannot use select option directly in the FM
‎2008 Apr 16 4:13 AM
Hi,
see the usage of FM,
Compare with you code and fields
DATA : l_skb1 like skb1.
data: l_amount like fdes-wrshb.
call function 'CONVERT_TO_FOREIGN_CURRENCY'
exporting
date = sy-datum
foreign_currency = l_skb1-waers---This is a structure
local_amount = fdes-wrshb
local_currency = fdes-dispw
importing
foreign_amount = l_amount
exceptions
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
others = 6.
‎2008 Apr 16 4:18 AM
Hi Kumar,
Have a look the following .
Regards,
Venkat.O
LOOP AT it_detail.
IF s_waers[] IS NOT INITIAL.
"Select-Option s_waers is a internal table
"You cant pass s_waers as a variable, as foreign_currency in CONVERT_TO_FOREIGN_CURRENCY function module.
"What you have to do is read the table s_waers for perticalular currency and pass through function module
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
date = sy-datum
foreign_currency = s_waers " You cant pass like this as s_waers is internal table.
local_amount = it_detail-dmbtr
local_currency = bkpf-waers
type_of_rate = 'M'
IMPORTING
foreign_amount = it_detail-dmbtr.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDLOOP.
‎2008 Apr 16 6:15 AM
Hi Venkat
S_waers is not an internal table. It is selection screen field
‎2008 Apr 16 6:19 AM
No its an internal table if use select-options for s_waers then its an internal table
‎2008 Apr 16 6:27 AM
hi kumar,
it is a selection-screen field and at the same time an internal table with the following structure.
sign type c
option type char02
low type werks
high type werks
regards,
Peter