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

How to convert amount

Former Member
0 Likes
2,732

Hi all,

I can get amount having format as 500 ,500.0 or 500.00.

But I should always convert it 500.00.

Please let me know how should this be achieved?

Regards

Taranam

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,027

Just declare the result variable as Packed integer with two decimals.

Please reward points if useful.

5 REPLIES 5
Read only

Former Member
0 Likes
2,027

Hi,

Define Packed number as

DATA p(13) type p decimals 2.

And move your data to this variable and use this variable for display purpose.

Thanks,CS reddy.

****Please Reward if helpful.

Read only

Former Member
0 Likes
2,028

Just declare the result variable as Packed integer with two decimals.

Please reward points if useful.

Read only

Former Member
0 Likes
2,027

just define the data as DMBTR and it will take care of format itself..

e.g.

parameter : amount type dmbtr obligatory.

write:/ amount.

Reward points if useful, get back in case of query...

Cheers!!!

Read only

Former Member
0 Likes
2,027

Hi,

Look at the below sample program


report zeta_amount.
 
data: input type  bapicurr-bapicurr .
data: c(20) type c.
data: output(15) type p decimals 2.
 
 
c = '215,654.54'.
 
clear sy-subrc.
while sy-subrc = 0.
  replace ',' with space into c.
endwhile.
condense c no-gaps.
input = c.
 
call function 'BAPI_CURRENCY_CONV_TO_INTERNAL'
  exporting
    currency                   = 'USD'
    amount_external            = input
    max_number_of_digits       = 20
 importing
    amount_internal            = output
*   RETURN                     =
          .
 
check sy-subrc = 0.

Regards

Sudheer

Read only

Former Member
0 Likes
2,027

Hi,

Go to tCode SU01 and input user name and click on change button and go to default tab in that yuo can Decimal Notation to 1,234,567.89.

By this all amount value will be with 2 decimals.

Or if programmatically.

You can declare your internal table field with BSIS-WRBTR.

Thanks,

Sriram Ponna.