Application Development 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: 

how to read a decimal from string

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

you can use

SPLIT lv_val at '.' into f1 f2.

Vijay.

Former Member
0 Kudos

Hi,

SPLIT lv_val AT '.' INTO lv_val1 lv_val2.

Thanks,

Krishna

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

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

for the correct syntax check F1 help..

regds,

M...

0 Kudos

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.

Former Member
0 Kudos

Hi,

SPLIT lv_val AT '.' INTO lv_val1 lv_val2.

concatenate lv_val2 '.' into lv_val3.

Regards,

Suresh.

Former Member
0 Kudos

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