Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8451

Need to get decimal Format.

$
0
0

Hi.

I am facing one problem.

The values are storing in variable as '2.5' Some times like '49.9'.

 

What i need is    2.5  then 2.5

                         2.6  then 3

                         2.1  then 2

If the value is equal to or more than half then next number has to come.

I checked.

----------------------------------

Round up:

DATA: V_INPUT TYPE NETPR VALUE '2.5'.

DATA: V_OUTPUT TYPE I.

 

V_OUTPUT = ceil( V_INPUT ).

 

WRITE: / V_OUTPUT.


Out put is :  3 But i need 2.5 


If input is  '4.95'

Output is 5  correct but in the case of 2.5  goes wrong.

-----------------------------------

Round down:

Input is  2.5  output is 2 not working

input is 3.5  output is 3  not working.


----------------------------------

Using function module.

DATA: X TYPE P VALUE '2.5',

       Y TYPE P DECIMALS 2.

 

CALL FUNCTION 'ROUND'

   EXPORTING

     DECIMALS = 1

     INPUT    = X

   IMPORTING

     OUTPUT   = Y.

*WRITE: x LEFT-JUSTIFIED.

WRITE: X.


Input as  '49.91' output 50  working

Output as '2.5' output 3  not working i need  2.5

How could i solve the issue.


Viewing all articles
Browse latest Browse all 8451

Trending Articles