2007 Nov 20 2:20 AM
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
2007 Nov 20 2:33 AM
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
2007 Nov 20 3:53 AM
Hi
Use the following for rounding:
Data : abc type i.
abc = round (<givennumber to be rounded>).
Thanks
Vijay
PLZ reward points if helpful
2016 May 10 12:00 PM
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