‎2013 Jun 04 6:11 PM
Hi guys, this is probably very basic for you guys, but for me as non programmer its quite tricky. I trying to build a query and have net prices in different currencys. I added an additonal field to convert them to euro, by multiplying with VBKD-KURSK. However the result value is 100000 times to high. VBKD-KURSK is defined as P, 5 dec. hence the values are always something like 1,53430. Yet the outcome is like it was 153430.
What did I miss ? Thanks
‎2013 Jun 04 8:54 PM
Hi.
Do not multiple, you can use a function that does that.
have a look this code
IF wa_datos-waers <> 'CLP' AND wa_datos-waers IS NOT INITIAL.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = sy-datum
foreign_amount = wa_datos-preis
foreign_currency = wa_datos-waers
local_currency = 'CLP'
IMPORTING
local_amount = wa_datos-preis_s_l.
wa_datos-preis = wa_datos-preis_s_l .
wa_datos-waers = 'CLP'.
Regards
Miguel A. Alvear
‎2013 Jun 05 3:30 AM
Hi Matthias,
Seems there is a small gap in your understanding. Your Coding is fine just check the thousand separator set in your profile. Steps are - Go to T-code SU03 and see screenshot
Your Decimal would be set as ',' as shown above i.e. 1,53430 is actually 1(decimal)53430.
BR,
Ankit.
‎2013 Jun 05 5:47 AM
Hi,
You can use FM SD_WF_ORDER_CONVERT_COMPCURR .
Better is use FM to get value instead of using manual calculation.
you can try below sample code....
CALL FUNCTION 'SD_WF_ORDER_CONVERT_COMPCURR'
EXPORTING
COMPCURRENCY = <LCL_CURR>
COMPANYCODECURRENCY = <LCL_CURR>
DOCUMENTCURRENCY = <DOC_CURR>
NETVALUE = <DOC_NET_VALUE>
EXCHANGERATE = <DOC_EXCH_RATE>
IMPORTING
NETVALUECC = <OUT_LCL_VALUE>
EXCEPTIONS
NO_RATE_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Mordhwaj
‎2013 Jun 05 8:48 PM
You are probably in an SD userexit, so living inside of one of the SAPFV45... programs. In these programs, the fixed point arithmetic is switched off. All numbers packed decimals are considered as integers. This should explain your result:
Docu data element FIXPT:
In program with no fixed-point arithmetic,
packed numbers (ABAP/4 type P, Dictionary types CURR, DEC
or QUAN) will be treated as integers when they are used in assignments,
comparisons, and calculations, irrespective of the number of decimal
places defined. Intermediate results in arithmetic calculations will
also be rounded to the next whole number. The number of decimal places
defined is only taken into account when you output the answer using the
WRITE statement.
Regards,
Rüdiger