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 Decimal

Former Member
0 Likes
780

Hi,

I'm ABAP beginner, how can i round the decimal number to an integer in ABAP report or SAPScript?? Which FM should i use??

Regards,

Kit

3 REPLIES 3
Read only

Former Member
0 Likes
607

Hi

Check this Sample

DATA n TYPE p DECIMALS 2.

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

n = abs( m ). WRITE: 'ABS: ', n.

n = sign( m ). WRITE: / 'SIGN: ', n.

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

n = floor( m ). WRITE: / 'FLOOR:', n.

n = trunc( m ). WRITE: / 'TRUNC:', n.

n = frac( m ). WRITE: / 'FRAC: ', n.

ULINE.

  • floating points

DATA: result TYPE f,

pi(10) TYPE c VALUE '3.14159265'.

result = cos( pi ).

WRITE result.

Thanks,

Praveen

Read only

Former Member
0 Likes
607

Hi

Use the following for rounding:

Data : abc type i.

abc = round (<givennumber to be rounded>).

Thanks

Vijay

PLZ reward points if helpful

Read only

Former Member
0 Likes
607

Hi All

Use the below code and it is so simple

data(lv_round) = round( val = '5678.65800341' dec = 0 ).


lv_round will be 5679

For 2 decimal places

data(lv_round) = round(  val = '5678.65800341' dec = 2  ).


lv_round will be 5678.66


data(lv_round) = round(  val = '5678.65300341' dec = 2  ).


lv_round will be 5678.65


For 5 decimals


data(lv_round) = round(  val = '5678.65800741' dec = 5 ).


lv_round will be 5678.65801


data(lv_round) = round(  val = '5678.65800341' dec = 5 ).


lv_round will be 5678.65800


Thanks,

Murugan