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

Function Module to Convert Amount to the Right Decimal

Former Member
0 Likes
35,069

Hi,

There is a function module that helps convert currency without decimals into the right format. For eg if the amount in BSEG table is in Taiwanese Dollars it will be displayed as 17.95 whereas the real amount is 1795.

So there is a function module which will convert the amount of 17.95 to 1795 (which can be used in a report for eg), once we pass the amount and the currency.

Any help would be greatly appreciated.

Thanks in advance.

Mick

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
12,301

follow the link

http://www.geocities.com/victorav15/sapr3/abapfun.html

try the function modules

ROUND – Rounds value to a number of decimal places . . .

ROUND_AMOUNT – Rounding based on company and currency

G_DECIMAL_PLACES_GET – Number of decimal places set for currency

hope it helps do reward.

Edited by: sharad narayan on Mar 7, 2008 11:34 AM

follow the link

http://www.geocities.com/victorav15/sapr3/abapfun.html

try the function modules

ROUND – Rounds value to a number of decimal places . . .

ROUND_AMOUNT – Rounding based on company and currency

G_DECIMAL_PLACES_GET – Number of decimal places set for currency

hope it helps do reward.

Edited by: sharad narayan on Mar 7, 2008 11:34 AM

10 REPLIES 10
Read only

Former Member
0 Likes
12,301

hi ,

if it is always 2 decimals then can multiply with 100 to get the data into a variable and pass it to the final output.

reward points if useful,

venkat.

Read only

0 Likes
12,301

Thanks Venkat for the reply.

If there is a standard function module available, then would like to use it rather then trying to write some logic for it.

Regards,

Mick

Read only

Former Member
0 Likes
12,302

follow the link

http://www.geocities.com/victorav15/sapr3/abapfun.html

try the function modules

ROUND – Rounds value to a number of decimal places . . .

ROUND_AMOUNT – Rounding based on company and currency

G_DECIMAL_PLACES_GET – Number of decimal places set for currency

hope it helps do reward.

Edited by: sharad narayan on Mar 7, 2008 11:34 AM

Read only

0 Likes
12,301

Thanks Sharad and Vasant.

What I am looking for is a function module, to which I will pass the amount from BSEG (17.95) and the currency TWD and it will return 1795 in TWD.

Hope its clear.

Read only

0 Likes
12,301

Hi Mick James,

Did you get the solution for your question in this thread?

I am also looking for this conversion, can you please share the answer if you know?

Thanks,

RV

Read only

0 Likes
12,301

Hi,

You'd better ask a new question to be helped by the whole community instead of asking one person!

Anyway, you may use WRITE amount CURRENCY 'TWD' TO l_field_char.

Sandra

Read only

0 Likes
12,301

hi,

1. Use WRITE statement:

DATA dmbtr TYPE bseg-dmbtr VALUE '17.95'.

DATA lv_amount_c(30) TYPE c.

WRITE dmbtr CURRENCY 'TWD' TO lv_amount_c.

WRITE LV_AMOUNT_C NO-GAP.

2. call BAPI

DATA: amount_in LIKE bapicurr-bapicurr VALUE '17.95',

amount_ex LIKE bapicurr-bapicurr .

CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'

EXPORTING

currency = 'TWD'

amount_internal = amount_in

IMPORTING

amount_external = amount_ex.

WRITE: / amount_in,amount_ex.

Read only

Former Member
0 Likes
12,301

Hello,

Make use of this sample:


REPORT ZV_CONVERT_CURR .
DATA : L_NETWR TYPE VBAP-NETWR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
     EXPORTING
          DATE             = SY-DATUM
          FOREIGN_AMOUNT   = '10.00'
          FOREIGN_CURRENCY = 'INR'
          LOCAL_CURRENCY   = 'EUR'
     IMPORTING
          LOCAL_AMOUNT     = L_NETWR
     EXCEPTIONS
          NO_RATE_FOUND    = 1
          OVERFLOW         = 2
          NO_FACTORS_FOUND = 3
          NO_SPREAD_FOUND  = 4
          DERIVED_2_TIMES  = 5
          OTHERS           = 6.


WRITE: L_NETWR.

Cheers,

Vasanth

Read only

justine_t_babu
Explorer
0 Likes
12,301

Try using the FM CURRENCY_AMOUNT_SAP_TO_DISPLAY.

Read only

Former Member
12,301

Answer is to use the BAPI function designed for that purpose:

Data: Result type bapicurr-bapicurr

CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
    EXPORTING
      currency        = 'JPY
      amount_internal = '10'
    IMPORTING
      amount_external = Result.

It will Display 1000 Yen by converting the amount based on TCURX values