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

number conversions!?!?!

Former Member
0 Likes
1,103

hi, suppose that i have this number -> 0,6027395, how can i get from it only 0,602 and not 0.603???!??!?!

Anyone

Thk, Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,083

Hi

try this, seems to work(not sure)

data:

w_pack type p decimals 8 value '0.6027395',

w_rounded type p decimals 3.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 3

input = w_pack

SIGN = '-'

IMPORTING

OUTPUT = w_rounded

  • 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.

write:w_rounded.

hi, suppose that i have this number -> 0,6027395, how can i get from it only 0,602 and not 0.603???!??!?!

Anyone

Thk, Regards

9 REPLIES 9
Read only

Former Member
0 Likes
1,083

I think you can't do it...

Greetings,

Blag.

Message was edited by:

Alvaro Tejada Galindo

Read only

0 Likes
1,083

Hi ,

yep Alvaro is right once again.

Greetings

Caglar

Message was edited by:

Caglar Ozkor

Read only

0 Likes
1,083

Hi Caglar:

Yeah....my mistake -:P I edited my message cause of course TRUNC would help....But FRAC is still giving 0.603 instead of 0.602...

Greetings,

Blag.

Read only

0 Likes
1,083

Hi Alvaro ,

I didn't try it and you are right , my mistake sorry

It's not working..

Regards

Caglar

Read only

former_member582701
Contributor
0 Likes
1,083

DATA: v_decimals3 TYPE P DECIMALS 3.

v_decimals3 = your_number.

Read only

Former Member
0 Likes
1,084

Hi

try this, seems to work(not sure)

data:

w_pack type p decimals 8 value '0.6027395',

w_rounded type p decimals 3.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 3

input = w_pack

SIGN = '-'

IMPORTING

OUTPUT = w_rounded

  • 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.

write:w_rounded.

Read only

0 Likes
1,083

It works -:D Nice <b>Rajesh</b>, didn't knew that function -:P

Greetings,

Blag.

Read only

0 Likes
1,083

Cheers Alvaro.

Read only

Former Member
0 Likes
1,083

Hi ,

A bit of math would do it as well.

v_num1 = v_num * 1000.

v_num2 = floor( v_num1 ).

v_num = v_num2 / 1000.

Regards,

Ravi