cancel
Showing results for 
Search instead for 
Did you mean: 

Want to truncate the integer part of a number

Former Member
0 Kudos

hi gurus

My requirement is round off a decimal value

in such a fashion that

if is 12.7767898 then convert to 12.50

again if it is 12.498989 convert to 12.50.

please help

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use this function..

J_1I6_ROUND_TO_NEAREST_AMT

I think it will serve u..

Answers (3)

Answers (3)

Former Member
0 Kudos

this does not works

Former Member
0 Kudos

You could do something like this:


DATA: number(16) TYPE P DECIMALS 4. 
           whole_part(16) TYPE C,
           remainder(4) TYPE C, 
           value(20) TYPE C.


MOVE number TO value.
SPLIT value AT ',' INTO whole_part remainder.

Then, examine the remainder:


IF remainder(1) GE '5'.
  remainder = '5000'.
ELSE.
* do something else
ENDIF.

CONCATENATE whole_part ',' remainder INTO value.

In your data display method, display this character string (value) instead of the numerical value (number).

This is a bit unfortunate because you have to type cast your value to string, but it works well enough. Just make sure you don't have any arithmetical operations on this newly created data field because you will get an exception.

Also, please note that this is not the complete solution, but only to give you an idea.

Regards,

SD

former_member210123
Active Participant
0 Kudos

WRITE pack ROUND 2 DECIMALS 4.

FM - CATSXC_ROUND_QUANTITY

FIMA_NUMERICAL_VALUE_ROUND

Former Member
0 Kudos

hai

there is fm 'ROUND' ..APPLY THIS FUNCTION MODULE.

IF U WANT TO GET FOLLOWING.

FOR THIS 12.06666..IF U WANT TO GET ONLY 12.

USE 'CEIL(12.066666)'

FOR THIS 12.789 ,,IF U WANT TO GET ONLY 13.

USE ''FLOOR(12.789) ..SEE THIS.