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

ROUNDING UP A VARIABLE

Former Member
0 Likes
1,162

Hi guys,

need some help. i have a numeric field which gives some value say 101.000

i want to remove that '.000'. Is it possible . please reply urgently

8 REPLIES 8
Read only

Former Member
0 Likes
1,115

Data : l_int_val type i.

move l_dec_val to l_int_val . "l_dec_val is ur variable that has the deimal val

this l_int_val will hold 101.

Else you can use CEIL and FLOOR to derive the upper and lower limits during rounding.

l_int_val = CEIL( l_dec_val )

l_int_val = FLOOR( l_dec_val ).

Hope it solves ur prob.

Read only

Former Member
0 Likes
1,115

data type i.

move that variable to another variable of type i.

then again assign it to that perivious variable...

var1 = 101.00.

data : var2 type i.

var1 = var2.

var2 = var1.

reward if helpful.

Message was edited by:

Kaushik Datta

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,115

hi p347633,

do you want to remove (as you wrote in your question) or do you want to round up (as you wrote in the subject)?

For round up you can use the FM ROUND the following way:

DECIMALS : the number of decimals you want to have after rounding (of course can be zero as well, that is rounding to integer)

SIGN: the way to round: '+' always up, '-' always down, 'X' mathematical

the removing you can do with this FM as well, or you can use the bulit in function TRUNC.

hope this helps

ec

Read only

Former Member
0 Likes
1,115

Declare one more character data type variable.Then pass the numeric field value to character data type variable while displaing the field value..It will avoid the "000"

Read only

Former Member
0 Likes
1,115

Hi,

Check the following code:

DATA pack TYPE p VALUE '12543.000'

DECIMALS 3.

WRITE pack DECIMALS 2.

WRITE: / pack DECIMALS 0.

WRITE: / pack ROUND -2,

/ pack ROUND -1,

/ pack ROUND 1,

/ pack ROUND 2.

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,115

DATA pack TYPE p VALUE '12543.000' DECIMALS 3.

Data : pack1 type decimals 0.

move pack to pack1.

Read only

Former Member
0 Likes
1,115
Hi,

hope this helps

REPORT ychatest2.

DATA : l_out TYPE p DECIMALS 3,
        l_outc(10).

l_out = '123.000'.
l_outc = l_out.

CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
  CHANGING
    c_value = l_outc.

TRANSLATE l_outc USING '. '.
WRITE : / l_outc.
Read only

Former Member
0 Likes
1,115

hi,

data: var type float value '100.000'.

data zvar type p DECIMALS 0.

zvar = var.

write zvar.

<b>output is 100</b>

plz reward points if it helps

rgds