Skip to Content
0
Former Member
Nov 12, 2007 at 11:41 AM

Currency Conversion

23 Views

Hello folks,

i am a total beginner, so please forgive me my stupid questions.

I am using the code below for currency conversion. It works fine. However i wonder why the field ld_erate is of type char. And how can abap do aritmetics like

ld_erate = t_er * ( t_lf / t_ff ) .

with a char-string. Is there a good document that explains this or similar operations?

Thanks in advance...

  DATA:
      gd_fcurr TYPE tcurr-fcurr,
      gd_tcurr TYPE tcurr-tcurr,
      gd_date  TYPE sy-datum,
      gd_value TYPE i,
      t_er        TYPE tcurr-ukurs,
      t_ff        TYPE tcurr-ffact,
      t_lf        TYPE tcurr-tfact,
      t_vfd       TYPE datum,
      ld_erate(12)   TYPE c.


gd_tcurr = 'EUR'.
gd_date  = sy-datum.
gd_value = SOURCE_FIELDS-/BIC/ZFPN_KZ1.
gd_fcurr = SOURCE_FIELDS-CURRENCY.


  CALL FUNCTION 'READ_EXCHANGE_RATE'
    EXPORTING
*       CLIENT                  = SY-MANDT
      date                    = gd_date
      foreign_currency        = gd_fcurr
      local_currency          = gd_tcurr
      TYPE_OF_RATE            = 'M'
*       EXACT_DATE              = ' '
   IMPORTING
      exchange_rate           = t_er
      foreign_factor          = t_ff
      local_factor            = t_lf
      valid_from_date         = t_vfd
*       DERIVED_RATE_TYPE       =
*       FIXED_RATE              =
*       OLDEST_RATE_FROM        =
   EXCEPTIONS
     no_rate_found           = 1
     no_factors_found        = 2
     no_spread_found         = 3
     derived_2_times         = 4
     overflow                = 5
     zero_rate               = 6
     OTHERS                  = 7
            .
  IF sy-subrc EQ 0.
    ld_erate = t_er  * ( t_lf / t_ff ) .
    gd_value = gd_value * ld_erate.
  ENDIF.