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

Roundong Function Module

arvind_soni
Participant
0 Likes
936

Hi,

Is there any function module in SAP for rounding of the numbers e.g if 100.91 is passed it should show 101.00.

Thanks in advance

Arvind

9 REPLIES 9
Read only

anversha_s
Active Contributor
0 Likes
903

hi,

use

ceil

eg:

lold = 99.8.

lnew = ceil( lold ).

write lnew.

rgds

Anver

Read only

0 Likes
903

Anver ,

Can you tell me what should be syntax.

Thanks

Read only

0 Likes
903

hi,

DATA: ws_data TYPE p VALUE '9.90',
ws_data1 TYPE p.

ws_data1 = CEIL( ws_data ).

WRITE ws_data1.

rgds

Anver

Read only

0 Likes
903

CEIL itself is teh syntax

VAR1 = CEIL(VAR).

wat a CEIL does is - it gives the smallest integer number that is not smaller than the value of the argument arg.

Regards

- Gopi

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
903

Hi,

DATA n TYPE p DECIMALS 2.

DATA m TYPE p DECIMALS 2 VALUE '-5.55'.

n = ceil( m ). WRITE: / 'CEIL: ', n.

The output appears as follows:

CEIL: 5.00-

Read only

0 Likes
903

Hi,

DATA n TYPE p DECIMALS 2.

DATA m TYPE p DECIMALS 2 VALUE '5.25'.

n = ceil( m ). WRITE: / 'CEIL: ', n.

and the output is shown as ' 6.00' but it should be '5.00'.

Please let me know if any other method is there .

Read only

0 Likes
903

Hi,

It will return the lowest value.SInce 5 is less than 6,output is 5.

If you use floor ( 5.25 ),that will return you 6.But that will be the output even if you give floor (5.75).

You need to do manual programming.

Function

Result

abs

Absolute value of argument.

sign

Prefix of the argument : 1 x > 0

SIGN( x ) = 0 if x = 0

-1 x < 0

ceil

Smallest integer value not smaller than the argument.

floor

Largest integer value not larger than the argument.

trunc

Integer part of argument.

FRAC

Fraction part of argument.

Read only

0 Likes
903

hi jayathi,

a small correction in ur post.

floor -> give the lower round value.

5.5 -> 5

ciel -> give the highr rounded value.

5.5 -> 6.

keep doing the helps

rgds

Anver.

Read only

Former Member
0 Likes
903

Hi

use abs r ceil

check this example...

DATA: I TYPE I,

P TYPE P DECIMALS 2,

M TYPE F VALUE '-3.5',

D TYPE P DECIMALS 1.

P = ABS( M ). " 3,5

I = P. " 4 - business rounding

I = M. " -4

I = CEIL( P ). " 4 - next largest whole number

I = CEIL( M ). " -3

I = FLOOR( P ). " 3 - next smallest whole number

I = FLOOR( M ). " -4

I = TRUNC( P ). " 3 - integer part

I = TRUNC( M ). " -3

D = FRAC( P ). " 0.5 - decimal part

D = FRAC( M ). " -0.5

check this link

-charitha