Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Currency Conversion

Former Member
0 Likes
487

hi,

i need a currency conversion code from EUR to USD.pls any one can provide and explain it .

points will be reward.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
469


DATA : t_amount(16) TYPE p value '1000'.
DATA : l_amount(16) TYPE p.
 
 
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
  EXPORTING
*   CLIENT                  = SY-MANDT
    date                    = sy-datum
    foreign_amount          = t_amount
    foreign_currency        = 'EUR'
    local_currency          = 'USD'
    TYPE_OF_RATE            = 'M'
 IMPORTING
*   EXCHANGE_RATE           =
*   FOREIGN_FACTOR          =
    LOCAL_AMOUNT            =  l_amount
*   LOCAL_FACTOR            =
*   EXCHANGE_RATEX          =
*   FIXED_RATE              =
*   DERIVED_RATE_TYPE       =
* EXCEPTIONS
*   NO_RATE_FOUND           = 1
*   OVERFLOW                = 2
*   NO_FACTORS_FOUND        = 3
*   NO_SPREAD_FOUND         = 4
*   DERIVED_2_TIMES         = 5
*   OTHERS                  = 6
          .
IF sy-subrc  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
WRITE : l_amount.


3 REPLIES 3
Read only

Former Member
0 Likes
470


DATA : t_amount(16) TYPE p value '1000'.
DATA : l_amount(16) TYPE p.
 
 
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
  EXPORTING
*   CLIENT                  = SY-MANDT
    date                    = sy-datum
    foreign_amount          = t_amount
    foreign_currency        = 'EUR'
    local_currency          = 'USD'
    TYPE_OF_RATE            = 'M'
 IMPORTING
*   EXCHANGE_RATE           =
*   FOREIGN_FACTOR          =
    LOCAL_AMOUNT            =  l_amount
*   LOCAL_FACTOR            =
*   EXCHANGE_RATEX          =
*   FIXED_RATE              =
*   DERIVED_RATE_TYPE       =
* EXCEPTIONS
*   NO_RATE_FOUND           = 1
*   OVERFLOW                = 2
*   NO_FACTORS_FOUND        = 3
*   NO_SPREAD_FOUND         = 4
*   DERIVED_2_TIMES         = 5
*   OTHERS                  = 6
          .
IF sy-subrc  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
WRITE : l_amount.


Read only

Former Member
0 Likes
469

hi there....

for currency conversion , u need to use

"CONVERT_TO_LOCAL_CURRENCY"

function module. it has many elements, but you need to use only a few in importing, exporting etc. no need to use the exceptions part.

please find the following code example regarding your query::

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

LOCAL_CURRENCY = 'USD'

FOREIGN_CURRENCY = t_list-waers1

FOREIGN_AMOUNT = t_list-kbetr1

DATE = t_list-prsdt

RATE = 0

IMPORTING

LOCAL_AMOUNT = t_list-kbetr1.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

LOCAL_CURRENCY = 'USD'

FOREIGN_CURRENCY = t_list-waers1

FOREIGN_AMOUNT = t_list-amt1

DATE = t_list-prsdt

RATE = 0

IMPORTING

LOCAL_AMOUNT = t_list-amt1.

*************************************************************

foreign_currency is the currency u want to convert into.

do reward if helpful or get back if need further assistance.

Read only

Former Member
0 Likes
469

Kindlcy check this code and reward points if useful

DATA : t_amount(16) TYPE p value '1000'.
DATA : l_amount(16) TYPE p.
 
 
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
  EXPORTING
*   CLIENT                  = SY-MANDT
    date                    = sy-datum
    foreign_amount          = t_amount
    foreign_currency        = 'EUR'
    local_currency          = 'USD'
    TYPE_OF_RATE            = 'M'
 IMPORTING
    LOCAL_AMOUNT            =  l_amount

          .
IF sy-subrc  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
WRITE : l_amount...