06-24-2008 8:41 AM
hi all,
Could someone kindly tell me how to do "chop off" by any keyword or FM?
I want to do:
'3.15' result in '3.1'
'3.11' result in '3.1'
Thanks~
06-24-2008 8:50 AM
Hi Wenwen,
Below is the sample code. to chopoff the value..... just copy and paste it it will resolve your problem
&****************Reward Point if helpful**********&
REPORT zcctest.
data: val(10) type c value '312.87'.
data: result(10) type c.
data: flag type i value 0.
data: count type i value -1.
DO 10 TIMES.
COUNT = COUNT + 1.
CONCATENATE RESULT VAL+COUNT(1) INTO RESULT.
if flag = 1.
exit.
endif.
IF VAL+COUNT(1) = '.'.
FLAG = 1.
ENDIF.
ENDDO.
write: result.
06-24-2008 8:43 AM
06-24-2008 8:50 AM
I tried your solution, but it round off.
DATA: x TYPE p DECIMALS 2 VALUE '3.15',
y TYPE p DECIMALS 1.
And I got y = 3.2...
06-24-2008 8:49 AM
hi ,
Try the following code:
data:
no1 type p decimals 2 value '31.13',
no2 type p decimals 1.
no2 = no1.
write no2.
regards,
Jaya Vani
06-24-2008 8:50 AM
Hi Wenwen,
Below is the sample code. to chopoff the value..... just copy and paste it it will resolve your problem
&****************Reward Point if helpful**********&
REPORT zcctest.
data: val(10) type c value '312.87'.
data: result(10) type c.
data: flag type i value 0.
data: count type i value -1.
DO 10 TIMES.
COUNT = COUNT + 1.
CONCATENATE RESULT VAL+COUNT(1) INTO RESULT.
if flag = 1.
exit.
endif.
IF VAL+COUNT(1) = '.'.
FLAG = 1.
ENDIF.
ENDDO.
write: result.
06-25-2008 1:23 AM
06-25-2008 8:04 AM
try this sample
data: p1 type p DECIMALS 2 VALUE '3.15'.
data: p2 type p DECIMALS 1.
p2 = p1 * 10.
p2 = floor( p2 ) / 10.
write:/ 'floor', p2.