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

Remove the decimals value

Former Member
0 Likes
910

Dear All,

Any Idea to remove the decimals value from the text ? my parameter declare as Character type.

eg : i want from 10000.000 become 10000

thanks

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
865

data:val1 type p decimals 3 value '10000.000'.

data:val2(15) type c.

write val1 to val2 DECIMALS 0.

write val2.

6 REPLIES 6
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
866

data:val1 type p decimals 3 value '10000.000'.

data:val2(15) type c.

write val1 to val2 DECIMALS 0.

write val2.

Read only

Former Member
0 Likes
865

you either use round or ceil or floor functions...

or copy that var into a var of type int.

it'll get rounded off though.

Rehards,

Sumit Nene.

Read only

Former Member
0 Likes
865

Hi,

It's very simple Just Use Split syntax.

DATA : X(10) TYPE C VALUE '1000.00',

Y (7) TYPE C ,

Z(5) TYPE C.

Ex.

SPLIT X AT '.' INTO: Y Z.

Salil ....

Read only

Former Member
0 Likes
865

Check this code.


DATA amt(8) TYPE p DECIMALS 3 VALUE '10000.000'.

DATA int_amt TYPE i.

data c_amt(10) type c.

int_amt = amt.
c_amt = int_amt.
WRITE : 'Integer' , int_amt, 25 'Char', c_amt.

KR,

Advait

Read only

Former Member
0 Likes
865

Hi ,

use FM.

ROUND

E.g.

DATA : lv_amt1 TYPE p DECIMALS 4,

lv_amt2 TYPE p DECIMALS 0,

lv_places TYPE i VALUE '0'.

CALL FUNCTION 'ROUND'

EXPORTING

decimals = lv_places

input = lv_amt1 "gs_flatfile-item_cost

sign = 'X'

IMPORTING

output = lv_amt2

EXCEPTIONS

input_invalid = 1

overflow = 2

type_invalid = 3

OTHERS = 4.

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,

Vijay

Read only

Former Member
0 Likes
865

Dear All,

Any Idea to remove the decimals value from the text ? my parameter declare as Character type.

eg : i want from 10000.000 become 10000

thanks

hi,

for this we can use two method one is,

data : value type p decimals 0.

value = '10000.000'.

write : / value.

Output is = 10000

Second method,

data : value type i.

value = '10000.000'.

write : / value.

Output is = 10000

-


If u use packed decimals

data : value type p decimals 1.

value = '10000.000'.

write : / value.

Output is = 10000.0