FUNCTION zmoney_convert.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(DATE) TYPE D DEFAULT SY-DATUM
*" REFERENCE(FOREIGN_AMOUNT) TYPE CRMT_NET_VALUE
*" REFERENCE(FOREIGN_CURRENCY) TYPE CRMT_CURRENCY
*" REFERENCE(LOCAL_CURRENCY) TYPE CRMT_CURRENCY DEFAULT 'RMB'
*" EXPORTING
*" REFERENCE(EXCHANGE_RATE) TYPE UKURS_CURR
*" REFERENCE(FOREIGN_FACTOR) TYPE FFACT_CURR
*" REFERENCE(LOCAL_AMOUNT) TYPE CRMT_NET_VALUE
*" REFERENCE(LOCAL_FACTOR) TYPE FFACT_CURR
*"----------------------------------------------------------------------
DATA dest LIKE rfcdes-rfcdest .
IF sy-mandt = '777'.
dest = 'RFC_P01_666_GE'.
ELSEIF sy-mandt = '162'.
dest = 'RFC_P01_666_GE'.
ELSEIF sy-mandt = '137'.
dest = 'RFC_RS1_666_HQ'.
ENDIF .
CALL FUNCTION 'Z1CONVERT_TO_LOCAL_CURRENCY'
DESTINATION dest
EXPORTING
date = date
foreign_amount = foreign_amount
foreign_currency = foreign_currency
local_currency = local_currency
IMPORTING
exchange_rate = exchange_rate
foreign_factor = foreign_factor
local_amount = local_amount
local_factor = local_factor
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6.
local_amount = local_amount * local_factor / foreign_factor.
ENDFUNCTION.
FUNCTION Z1CONVERT_TO_LOCAL_CURRENCY.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(CLIENT) LIKE SY-MANDT DEFAULT SY-MANDT
*" VALUE(DATE) LIKE SYST-DATUM
*" VALUE(FOREIGN_AMOUNT) TYPE PBR_ACURR
*" VALUE(FOREIGN_CURRENCY) TYPE FCURR_CURR
*" VALUE(LOCAL_CURRENCY) TYPE TCURR_CURR
*" VALUE(RATE) TYPE WT_RATEZ DEFAULT 0
*" VALUE(TYPE_OF_RATE) TYPE KURST_CURR DEFAULT 'M'
*" VALUE(READ_TCURR) TYPE CHAR1 DEFAULT 'X'
*" EXPORTING
*" VALUE(EXCHANGE_RATE) LIKE TCURR-UKURS
*" VALUE(FOREIGN_FACTOR) TYPE FFACT_CURR
*" VALUE(LOCAL_AMOUNT) TYPE PBR_ACURR
*" VALUE(LOCAL_FACTOR) TYPE FFACT_CURR
*" VALUE(EXCHANGE_RATEX) TYPE PBR_ACURR
*" VALUE(FIXED_RATE) TYPE UKURS_CURR
*" VALUE(DERIVED_RATE_TYPE) LIKE TCURR-KURST
*" EXCEPTIONS
*" NO_RATE_FOUND
*" OVERFLOW
*" NO_FACTORS_FOUND
*" NO_SPREAD_FOUND
*" DERIVED_2_TIMES
*"----------------------------------------------------------------------
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = CLIENT
DATE = DATE
FOREIGN_AMOUNT = FOREIGN_AMOUNT
FOREIGN_CURRENCY = FOREIGN_CURRENCY
LOCAL_CURRENCY = LOCAL_CURRENCY
RATE = RATE
TYPE_OF_RATE = TYPE_OF_RATE
READ_TCURR = READ_TCURR
IMPORTING
EXCHANGE_RATE = EXCHANGE_RATE
FOREIGN_FACTOR = FOREIGN_FACTOR
LOCAL_AMOUNT = LOCAL_AMOUNT
LOCAL_FACTOR = LOCAL_FACTOR
EXCHANGE_RATEX = EXCHANGE_RATEX
FIXED_RATE = FIXED_RATE
DERIVED_RATE_TYPE = DERIVED_RATE_TYPE
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
CASE SY-SUBRC.
WHEN 1.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING NO_RATE_FOUND.
WHEN 2.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING OVERFLOW.
WHEN 3.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING NO_FACTORS_FOUND.
WHEN 4.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING NO_SPREAD_FOUND.
WHEN 5.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING DERIVED_2_TIMES.
WHEN 6.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING OTHERS.
ENDCASE.
ENDFUNCTION.
阅读(2332) | 评论(0) | 转发(0) |