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

read only decimal value

Former Member
0 Likes
6,186

hello friends,

I have requirement to read the value after decimal point.. for eg: if value is 125.28, I need to convert it to 0.28.

please suggest

thanks in advance.

Bharat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,527

Hi,

try this:



data: p1 type p DECIMALS 2 value '123.28'.
data: p2 type p DECIMALS 2.
*
p2 = p1 mod 1.
*

Regards, Dieter

11 REPLIES 11
Read only

Former Member
0 Likes
3,527

HI !!

Just assign this value to any string variable and split at '.'

or

Use this code snippet

DATA lv_var1 TYPE p DECIMALS 2 VALUE '10.25'.
DATA lv_var2 TYPE p DECIMALS 2.
lv_var2 = FRAC( lv_var1 ).
WRITE: / lv_var2.

Thanks

Read only

Former Member
0 Likes
3,527

Hi,

125.28, I need to convert it to 0.28

data: string1 type string

string2 type string.

string1 = '125.28'.

split string1 at '.' into string1 string2.

now string2 contains .28.

Then

concatenate '0' string2 into string2.

now string2 = 0.28.

regards

sekhar.

Read only

Former Member
0 Likes
3,527

Hi Bharat,

you can use link

Regards,

Vijay

Read only

Former Member
0 Likes
3,527

hi,

please use SPLIT statement at decimal point like '. press F1 on isplit t and read the help documnets

then concatenate the value.

thanks

Read only

Former Member
0 Likes
3,527

Hi,

This is very simple, there are 2 possibility

data: var1 type string default '125.28',

var2 type string.

split var1 at '.' into var1 var2.

concatenate '0' var2 into var2.

write:/var2 .

OR

data: var1(6) type c default '125.28',

var2(4) type c.

var2 = var1+3(3).

concatenate '0' var2 into var2.

write:/var2 .

Hope this may help you.

Pooja

Read only

Former Member
0 Likes
3,527

HI Bharat,

This will solve your query.

DATA wa_int(3) TYPE p decimals 2 value '6.78'.

DATA wa_int1(3) TYPE p decimals 2.

wa_int1 = frac( wa_int ). "returns 0.78

Revert if you need more.

Thanks.

Read only

Former Member
0 Likes
3,528

Hi,

try this:



data: p1 type p DECIMALS 2 value '123.28'.
data: p2 type p DECIMALS 2.
*
p2 = p1 mod 1.
*

Regards, Dieter

Read only

0 Likes
3,527

> Hi,

>

> try this:

>

>


> 
> data: p1 type p DECIMALS 2 value '123.28'.
> data: p2 type p DECIMALS 2.
> *
> p2 = p1 mod 1.
> *
> 
> 

>

> Regards, Dieter

The beauty of simplicity!

Read only

0 Likes
3,527

Dear Dieter,

problem got solved...thanks for ur help....

thanks everyone for the reply....

thanks,

Bharat

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,527

use FRAC function ..that is is the best method

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,527

hi bharat kumar

The points must go to dieter