11-12-2007 11:41 AM
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.
11-12-2007 11:46 AM
Hi at the right side of the = the calculation is done..
and then we are storing the value in the left side variable...
For more info about data type and conversion..
Go through below link..
For learning ABAP data types
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/ch07.htm
it will really help you a lot...
and for Conversion of data type..
See the DATA conversion topic of below link..
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/ch09.htm#AssignmentStatements
<b>Reward points if it is helpul</b>
Thanks & Regards
ilesh 24x7
11-12-2007 11:45 AM
in ur code u r doing operations on fields whose type is decimal and not character....
tcurr-ffact,tfact,ukurs all are of type decimal 9.
after doing the operation u r storing it in charecter type variable......!!!!!!
11-12-2007 11:46 AM
Hi at the right side of the = the calculation is done..
and then we are storing the value in the left side variable...
For more info about data type and conversion..
Go through below link..
For learning ABAP data types
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/ch07.htm
it will really help you a lot...
and for Conversion of data type..
See the DATA conversion topic of below link..
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/ch09.htm#AssignmentStatements
<b>Reward points if it is helpul</b>
Thanks & Regards
ilesh 24x7