* 获取汇率
FORM GET_KURSF USING IM_WAERS TYPE BKPF-WAERS
IM_BUDAT TYPE BKPF-BUDAT
CHANGING L_RATE TYPE BKPF-KURSF.
DATA: CW_RATE LIKE BAPI1093_0.
DATA: S_C_FACTOR TYPE P DECIMALS 3,
T_C_FACTOR TYPE P DECIMALS 3.
DATA: FIRST_DAY TYPE SY-DATUM.
CONCATENATE IM_BUDAT(6) '01' INTO FIRST_DAY.
*1. 获取汇率信息
CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
EXPORTING
RATE_TYPE = 'M' "汇率类型
FROM_CURR = IM_WAERS "开始货币
TO_CURRNCY = 'CNY' " 目标货币
DATE = FIRST_DAY
IMPORTING
EXCH_RATE = CW_RATE.
L_RATE = CW_RATE-EXCH_RATE.
* L_RATE = CW_RATE-EXCH_RATE * ( CW_RATE-TO_FACTOR / CW_RATE-FROM_FACTOR ).
ENDFORM.