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

Find . in a string

Former Member
0 Likes
1,813

Hi,

I have a string which contains 43.555.

I would like to find the number occurred after a ".".

Let me know which function to use.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,530

search '.' in YOUR_STRING.

the position of your dot is beeing published in sy-fdpos, if found.

Strlen( YOUR_STRING ) gives you the length of your string.

length of string - position of dot = number of characters after dot.

7 REPLIES 7
Read only

Former Member
0 Likes
1,531

search '.' in YOUR_STRING.

the position of your dot is beeing published in sy-fdpos, if found.

Strlen( YOUR_STRING ) gives you the length of your string.

length of string - position of dot = number of characters after dot.

Read only

Former Member
0 Likes
1,530

u can try to do:

split text at '.' into text1 text2.

not sure if it woks with numbers tho.

Read only

0 Likes
1,530

Hi,

Try this.

Data : temp type string.

move num to temp. "num will hold 45.9999

split temp at '.' into str1 str2.

regards,

mallika

Read only

Former Member
0 Likes
1,530

Use split at dot, it wud be diveded into left and right strings then search the right number for ur pattern or number whatever u want

Read only

0 Likes
1,530

Hi,

Please use the following code:

DATA test type string.

DATA: num1 type string, num2 type string.

test = '43555'.

SPLIT test at '.' INTO num1 num2.

IF num2 is NOT INITIAL.

write: num2+0(1). -


> This will give you the number after '.' 5

ENDIF.

OR

inside IF.. ENDIF

write: num2. -


> This will give the numbers after '.'. 555

Best Regards,

Suresh

Read only

awin_prabhu
Active Contributor
0 Likes
1,530

Check this code.

REPORT zsample.

DATA: s TYPE string,

off TYPE i,

w type c.

s = '43.555'.

FIND '.' IN s MATCH OFFSET off.

off = off + 1.

w = s+off(1).

write: w.

Read only

Former Member
0 Likes
1,530

hi Krish,

You can do like this..

split text at '.' into t1 t2.

and then you can find the length of t2.

Regards,

Nitin