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

functon modules

Former Member
0 Likes
938

what is the predefind function module for round of the dispalyed valu (for ex NETWER value 12.34, but we want 12.00) ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
878

Hi,

Use ceil function

data: netwer type p decimals 2.

netwer = ceil(12.34).

write:/ netwer.

Regards

7 REPLIES 7
Read only

Former Member
0 Likes
879

Hi,

Use ceil function

data: netwer type p decimals 2.

netwer = ceil(12.34).

write:/ netwer.

Regards

Read only

Former Member
0 Likes
878

Hi,

Use ROUND FM to achieve this ...

data : orig_amt type p decimals 10 value '0.29846',

round_amt type p decimals 4.

call function 'ROUND'

exporting

decimals = 4

input = orig_amt

sign = '-'

importing

output = round_amt

exceptions

input_invalid = 1

overflow = 2

type_invalid = 3

others = 4.

write : round_am.

Hope thhis helps u,

Regards,

Arunsri

Read only

Former Member
0 Likes
878

CHk this thread.

Read only

Former Member
0 Likes
878

A number of rounding FMs with worked exmaples are in the book "common sap r/3 functions manual". Here are three witht he explanation it gives for the parameters. I think ROUND will work for you.

(1) HR_ROUND_NUMBER

(2) ROUND:

Parameters:

EXPORTING

DECIMALS Number of decimals places in output

INPUT Input quantity

SIGN Rounding type:

Value Meaning

examples

+ Round up (10.55 => 10.60)

- Round down (10.55 => 10.50)

X Commercial (10.55 => 10.60)

' ' No rounding (10.55 => 10.55)

(3) ROUND_AMOUNT:

Parameters:

EXPORTING

AMOUNT_IN Amount to be rounded

COMPANY Company code

CURRENCY Currency code

IMPORTING

AMOUNT_OUT Amount after rounding

DIFFERENCE Difference between Amount In and Amount Out

NO_ROUNDING Flag: no rounding setup for this company code and currency

ROUNDING_UNIT Unit to round up to

Do reward if helpful

Read only

Former Member
0 Likes
878

Hi,

Use CEIL keyword to get upper round figure, and use FLOOR keyword to get lower roud figure.

Ex: x = 12.34

CEIL(x) = 13.00.

FLOOR ( x) = 12.00.

Regards,

kavitha.

Read only

Former Member
0 Likes
878

Hi,

Use this code

fraction = FRAC( amount ) .

IF fraction GE '0.50' .

amount = CEIL( amount ) .

else .

amount = floor( amount ).

ENDIF .

t_output-pswbt_hec = amount .

O/p : if 1.3 it gives 1

if 1.7 it gives 2

regards,

Kannnan

Read only

Former Member
0 Likes
878

Hi,

u can use the FM "Round" to round the value to specfic decimal places . u can make round up, round down or commercial round.

Please find below a sample code for that.

DATA: VALUE TYPE F,

ROUND_VALUE TYPE F.

...

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 2-

INPUT = VALUE

SIGN = '+'

IMPORTING

OUTPUT = ROUND_VALUE

EXCEPTIONS

INPUT_INVALD = 01

OVERFLOW = 02

TYPE_INVALID = 03.

when the SIGN = SPACE there is no rounding which means OUTPUT= INPUT .

please reward points if useful.

regards

sandhya