SAP CONVERT_TO_FOREIGN_CURRENCY Function Module for Translate local currency amount into foreign currency









CONVERT_TO_FOREIGN_CURRENCY is a standard convert to foreign 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 local currency amount into foreign 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 foreign currency FM, simply by entering the name CONVERT_TO_FOREIGN_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_FOREIGN_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_FOREIGN_CURRENCY'"Translate local currency amount into foreign currency
EXPORTING
* CLIENT = SY-MANDT "
DATE = "Currency translation date
FOREIGN_CURRENCY = "Currency key for foreign currency
LOCAL_AMOUNT = "Amount in local 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_AMOUNT = "Amount in foreign currency
FOREIGN_FACTOR = "Factor for the foreign currency units
LOCAL_FACTOR = "Factor for the local currency units
EXCHANGE_RATEX = "Exchange rate 4.11
DERIVED_RATE_TYPE = "Alternative exchange rate, where used
FIXED_RATE = "Fixed exchange rate 4.5, if existent

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_FOREIGN_CURRENCY

CLIENT -

Data type: SY-MANDT
Default: SY-MANDT
Optional: Yes
Call by Reference: No ( called with pass by value option)

DATE - Currency translation date

Data type: SYST-DATUM
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_AMOUNT - Amount in local 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_FOREIGN_CURRENCY

EXCHANGE_RATE - Exchange rate 4.5

Data type:
Optional: 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_FACTOR - Factor for the foreign currency units

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)

DERIVED_RATE_TYPE - Alternative exchange rate, where used

Data type: TCURR-KURST
Optional: No
Call by Reference: No ( called with pass by value option)

FIXED_RATE - Fixed exchange rate 4.5, if existent

Data type:
Optional: 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 - Field FOREIGN_AMOUNT 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_FOREIGN_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_amount  TYPE SYST, "   
lv_foreign_factor  TYPE SYST, "   
lv_foreign_currency  TYPE SYST, "   
lv_no_factors_found  TYPE SYST, "   
lv_local_amount  TYPE SYST, "   
lv_local_factor  TYPE SYST, "   
lv_no_spread_found  TYPE SYST, "   
lv_exchange_ratex  TYPE SYST, "   
lv_local_currency  TYPE SYST, "   
lv_derived_2_times  TYPE SYST, "   
lv_rate  TYPE SYST, "   0
lv_derived_rate_type  TYPE TCURR-KURST, "   
lv_fixed_rate  TYPE TCURR, "   
lv_type_of_rate  TYPE TCURR, "   'M'
lv_read_tcurr  TYPE TCURR. "   'X'

  CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'  "Translate local currency amount into foreign currency
    EXPORTING
         CLIENT = lv_client
         DATE = lv_date
         FOREIGN_CURRENCY = lv_foreign_currency
         LOCAL_AMOUNT = lv_local_amount
         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_AMOUNT = lv_foreign_amount
         FOREIGN_FACTOR = lv_foreign_factor
         LOCAL_FACTOR = lv_local_factor
         EXCHANGE_RATEX = lv_exchange_ratex
         DERIVED_RATE_TYPE = lv_derived_rate_type
         FIXED_RATE = lv_fixed_rate
    EXCEPTIONS
        NO_RATE_FOUND = 1
        OVERFLOW = 2
        NO_FACTORS_FOUND = 3
        NO_SPREAD_FOUND = 4
        DERIVED_2_TIMES = 5
. " CONVERT_TO_FOREIGN_CURRENCY




ABAP code using 7.40 inline data declarations to call FM CONVERT_TO_FOREIGN_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).
 
 
 
 
 
 
 
 
 
 
 
 
 
"SELECT single KURST FROM TCURR INTO @DATA(ld_derived_rate_type).
 
 
DATA(ld_type_of_rate) = 'M'.
 
DATA(ld_read_tcurr) = 'X'.
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!