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

how to read a decimal from string

Former Member
0 Likes
1,519

Hi All,

lv_val = '21.45'.

how to read point( dot ) ?

i want to separate 21 and .45 ?

can u help me?

thanks,

srii.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,350

Hi,

you have lv_val = '21.45'.

Try this to know th position of dot in 'lv_val'

**********************************

data: L_Length type i.

IF lv_val CS '.'.

L_Length = SY_FDPOS.

ENDIF.

now L_Length will have the position of Dot in lv_val.

Regards,

Syed

7 REPLIES 7
Read only

Former Member
0 Likes
1,350

you can use

SPLIT lv_val at '.' into f1 f2.

Vijay.

Read only

Former Member
0 Likes
1,350

Hi,

SPLIT lv_val AT '.' INTO lv_val1 lv_val2.

Thanks,

Krishna

Read only

Former Member
0 Likes
1,350

Hi

Try this

DATA : VAL1   TYPE CHAR10 VALUE '21.45',
       PART1  TYPE CHAR05,
       PART2  TYPE CHAR05.

SPLIT VAL1 AT '.' INTO PART1 PART2.

WRITE : / PART1,
          PART2.

If your Input value is of type P you can do something like this..

DATA : VAL2       TYPE P decimals 2 VALUE '21.45',
       VAL2_CHAR  TYPE CHAR10,
       PART1      TYPE CHAR05,
       PART2      TYPE CHAR05.

VAL2_CHAR = VAL2.
CONDENSE VAL2_CHAR.

SPLIT VAL2_CHAR AT '.' INTO PART1 PART2.

WRITE : / PART1,
          PART2.

Regards

Edited by: Rajvansh Ravi on Oct 17, 2008 9:28 AM

Read only

Former Member
0 Likes
1,350

Hi,

Use the syntax 'Split' at '.' into a variabel...

for the correct syntax check F1 help..

regds,

M...

Read only

0 Likes
1,350

thanks for u replays and i will award the points.

lv_val = '214.5'.

how to read the dot posion?

for example: lv_val = 214.5 now the dot position is 3.

thank you,

srii.

Read only

Former Member
0 Likes
1,350

Hi,

SPLIT lv_val AT '.' INTO lv_val1 lv_val2.

concatenate lv_val2 '.' into lv_val3.

Regards,

Suresh.

Read only

Former Member
0 Likes
1,351

Hi,

you have lv_val = '21.45'.

Try this to know th position of dot in 'lv_val'

**********************************

data: L_Length type i.

IF lv_val CS '.'.

L_Length = SY_FDPOS.

ENDIF.

now L_Length will have the position of Dot in lv_val.

Regards,

Syed