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

Data Type Conversion VBKD- KURSK

Former Member
0 Likes
2,217

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

4 REPLIES 4
Read only

Former Member
0 Likes
1,289

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

Read only

Former Member
0 Likes
1,289

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.

Read only

Former Member
0 Likes
1,289

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

Read only

Ruediger_Plantiko
Active Contributor
0 Likes
1,289

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