SAP CONVERT_TO_LOCAL_CURRENCY Function Module for Translate foreign currency amount to local currency
CONVERT_TO_LOCAL_CURRENCY is a standard convert to local currency SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Translate foreign currency amount to local currency processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for convert to local currency FM, simply by entering the name CONVERT_TO_LOCAL_CURRENCY into the relevant SAP transaction such as SE37 or SE38.
Function Group: SCUN
Program Name: SAPLSCUN
Main Program: SAPLSCUN
Appliation area: *
Release date: 17-May-2000
Mode(Normal, Remote etc): Normal Function Module
Update:
Function CONVERT_TO_LOCAL_CURRENCY pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'"Translate foreign currency amount to local currency.
EXPORTING
* CLIENT = SY-MANDT "
DATE = "Currency translation date
FOREIGN_AMOUNT = "Amount in foreign currency
FOREIGN_CURRENCY = "Currency key for foreign currency
LOCAL_CURRENCY = "Currency key for local currency
* RATE = 0 "Predefined exchange rate
* TYPE_OF_RATE = 'M' "Type of rate M=Average rate G=Bank buying rate B=bank selling rate
* READ_TCURR = 'X' "Read exchange rate from table TCURR
IMPORTING
EXCHANGE_RATE = "Exchange rate 4.5
FOREIGN_FACTOR = "Factor for the foreign currency units
LOCAL_AMOUNT = "Amount in local currency
LOCAL_FACTOR = "Factor for the local currency units
EXCHANGE_RATEX = "Exchange rate 4.11
FIXED_RATE = "Fixed exchange rate 4,5, if present
DERIVED_RATE_TYPE = "Alternative exchange rate type, where used
EXCEPTIONS
NO_RATE_FOUND = 1 OVERFLOW = 2 NO_FACTORS_FOUND = 3 NO_SPREAD_FOUND = 4 DERIVED_2_TIMES = 5
IMPORTING Parameters details for CONVERT_TO_LOCAL_CURRENCY
CLIENT -
Data type: SY-MANDTDefault: SY-MANDT
Optional: Yes
Call by Reference: No ( called with pass by value option)
DATE - Currency translation date
Data type: SYST-DATUMOptional: No
Call by Reference: No ( called with pass by value option)
FOREIGN_AMOUNT - Amount in foreign currency
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
FOREIGN_CURRENCY - Currency key for foreign currency
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
LOCAL_CURRENCY - Currency key for local currency
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
RATE - Predefined exchange rate
Data type:Optional: Yes
Call by Reference: No ( called with pass by value option)
TYPE_OF_RATE - Type of rate M=Average rate G=Bank buying rate B=bank selling rate
Data type:Default: 'M'
Optional: Yes
Call by Reference: No ( called with pass by value option)
READ_TCURR - Read exchange rate from table TCURR
Data type:Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for CONVERT_TO_LOCAL_CURRENCY
EXCHANGE_RATE - Exchange rate 4.5
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
FOREIGN_FACTOR - Factor for the foreign currency units
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
LOCAL_AMOUNT - Amount in local currency
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
LOCAL_FACTOR - Factor for the local currency units
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
EXCHANGE_RATEX - Exchange rate 4.11
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
FIXED_RATE - Fixed exchange rate 4,5, if present
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DERIVED_RATE_TYPE - Alternative exchange rate type, where used
Data type: TCURR-KURSTOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
NO_RATE_FOUND - No exch.rate entered in table TCURR
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
OVERFLOW - LOCAL_AMOUNT field is too small
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_FACTORS_FOUND - No conversion factors in TCURF
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_SPREAD_FOUND - No spread entered in table TCURS
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DERIVED_2_TIMES - Exchange rate type derived more than once
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for CONVERT_TO_LOCAL_CURRENCY Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.DATA: | ||||
lv_client | TYPE SY-MANDT, " SY-MANDT | |||
lv_exchange_rate | TYPE SY, " | |||
lv_no_rate_found | TYPE SY, " | |||
lv_date | TYPE SYST-DATUM, " | |||
lv_overflow | TYPE SYST, " | |||
lv_foreign_factor | TYPE SYST, " | |||
lv_local_amount | TYPE SYST, " | |||
lv_foreign_amount | TYPE SYST, " | |||
lv_no_factors_found | TYPE SYST, " | |||
lv_local_factor | TYPE SYST, " | |||
lv_no_spread_found | TYPE SYST, " | |||
lv_foreign_currency | TYPE SYST, " | |||
lv_exchange_ratex | TYPE SYST, " | |||
lv_local_currency | TYPE SYST, " | |||
lv_derived_2_times | TYPE SYST, " | |||
lv_rate | TYPE SYST, " 0 | |||
lv_fixed_rate | TYPE SYST, " | |||
lv_type_of_rate | TYPE SYST, " 'M' | |||
lv_derived_rate_type | TYPE TCURR-KURST, " | |||
lv_read_tcurr | TYPE TCURR. " 'X' |
  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY' "Translate foreign currency amount to local currency |
EXPORTING | ||
CLIENT | = lv_client | |
DATE | = lv_date | |
FOREIGN_AMOUNT | = lv_foreign_amount | |
FOREIGN_CURRENCY | = lv_foreign_currency | |
LOCAL_CURRENCY | = lv_local_currency | |
RATE | = lv_rate | |
TYPE_OF_RATE | = lv_type_of_rate | |
READ_TCURR | = lv_read_tcurr | |
IMPORTING | ||
EXCHANGE_RATE | = lv_exchange_rate | |
FOREIGN_FACTOR | = lv_foreign_factor | |
LOCAL_AMOUNT | = lv_local_amount | |
LOCAL_FACTOR | = lv_local_factor | |
EXCHANGE_RATEX | = lv_exchange_ratex | |
FIXED_RATE | = lv_fixed_rate | |
DERIVED_RATE_TYPE | = lv_derived_rate_type | |
EXCEPTIONS | ||
NO_RATE_FOUND = 1 | ||
OVERFLOW = 2 | ||
NO_FACTORS_FOUND = 3 | ||
NO_SPREAD_FOUND = 4 | ||
DERIVED_2_TIMES = 5 | ||
. " CONVERT_TO_LOCAL_CURRENCY |
ABAP code using 7.40 inline data declarations to call FM CONVERT_TO_LOCAL_CURRENCY
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8."SELECT single MANDT FROM SY INTO @DATA(ld_client). | ||||
DATA(ld_client) | = SY-MANDT. | |||
"SELECT single DATUM FROM SYST INTO @DATA(ld_date). | ||||
DATA(ld_type_of_rate) | = 'M'. | |||
"SELECT single KURST FROM TCURR INTO @DATA(ld_derived_rate_type). | ||||
DATA(ld_read_tcurr) | = 'X'. | |||
Search for further information about these or an SAP related objects