经常用到,好不容易做了一个完整的。
data: cw_rate like bapi1093_0.
data: s_c_factor type p decimals 3,
t_c_factor type p decimals 3,.
data: s_waerk type waerk,
t_waerk type waerk,
curdate type rscalday,"add by Robin 2010.08.07
l_rate type p decimals 4.
data: s_c_factor type p decimals 3,
t_c_factor type p decimals 3,.
data: s_waerk type waerk,
t_waerk type waerk,
curdate type rscalday,"add by Robin 2010.08.07
l_rate type p decimals 4.
*1. 获取汇率信息
call function 'BAPI_EXCHANGERATE_GETDETAIL'
exporting
rate_type = 'M'
from_curr = s_waerk
to_currncy = t_waerk
date = curdate
importing
exch_rate = cw_rate.
exporting
rate_type = 'M'
from_curr = s_waerk
to_currncy = t_waerk
date = curdate
importing
exch_rate = cw_rate.
*2. 获取转换因子
call function 'CURRENCY_CONVERTING_FACTOR'
exporting
currency = s-waerk
importing
factor = s_c_factor.
call function 'CURRENCY_CONVERTING_FACTOR'
exporting
currency = s-waerk
importing
factor = s_c_factor.
call function 'CURRENCY_CONVERTING_FACTOR'
exporting
currency = t-waerk
importing
factor = t_c_factor.
exporting
currency = t-waerk
importing
factor = t_c_factor.
l_rate = cw_rate-exch_rate * ( cw_rate-to_factor / cw_rate-from_factor )
* ( s_c_factor / t_c_factor ) .
* ( s_c_factor / t_c_factor ) .