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

Substring

Former Member
0 Likes
1,238

How can i get substring from main string.

ex:mainstr = 'abcdefgh'.

i want sting excluding 'abc'.

9 REPLIES 9
Read only

Former Member
0 Likes
1,186

hi,

str = mainstr+3.

or replace 'abc' in mainstr with ''.

Regards,

Subramanian

Read only

Former Member
0 Likes
1,186

hi,

You can use.

substr = string+2(5).

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
1,186

Hi

str = mainstr+4(5) .

Regards,

Sravnthi.

Read only

Former Member
0 Likes
1,186

Hi Venkat,

if mainstr = 'abcdefgh'.

then mainstr+4(5) will give you the value 'defgh'.

Regards,

Asha

Read only

Former Member
0 Likes
1,186

Hi,

Write----

str = mainstr+3(5).

str is substring.

Regards,

Sujit

Read only

Former Member
0 Likes
1,186

Hi,

use the concept of offset

str = mainstr+2(5).

Regards,

Anirban

Read only

Former Member
0 Likes
1,186

Hi,

You can use the offset position and length of the string function

mainstr+offset(length)

in your case... you can use

string1 = mainstr+3.

It starts from 3rd offset position till the end of the string

if you want to specify the length you can also do that...

starting from 3 position you want to retrieve 3 chars then specify the length also

mainstr+3(3)

regards

padma

Read only

Former Member
0 Likes
1,186

hiii

you can get this value by using OFFSTE like

mainstr = 'abcdefgh'.

w_answer = mainstr+3(5).

or use like

mainstr CN 'abc'.

regards

twinkal

Read only

Former Member
0 Likes
1,186

hi

go through this

mainstr = 'abcdefgh'.

ex_srting = 'abc'

now get the length of ex_string. here it is 3

so length1 = 3.

lenght2 = 8

now use this

mainstr CS ex_string

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of ex_string in mainstr.

offset = SY-FDPOS + length1.
req_len = length - offset
req_str  = mainstr+offset(req_len ).

Cheers

Snehi