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 Character in string

Former Member
0 Likes
6,833

Hi All,

Can anybody tell me how to find that : how many times an particular character occurs in the string.

for eg.

if my string is : HI~this is the FirstLogin~.

i want to find the number of time that ~ character occurs in string.

please give me the solution.

thanks in advance.

vinod.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,367

FIND ALL OCCURENCES OF .... ==> SAPHelp!

FIND ALL OCCURENCES OF .... ==> SAPHelp!

5 REPLIES 5
Read only

Former Member
0 Likes
1,367

Hello,

Use CA -> Contains any operator.

if wa_temp CA '~'.

< >

endif.

Thanks,

Jayant

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,368

FIND ALL OCCURENCES OF .... ==> SAPHelp!

Read only

Former Member
0 Likes
1,367

Hi vinod,

Use the following code:

IF v_string CS '~'.

WRITE:/1 'Yes'.

ELSE.

WRITE:/1 'No'.

ENDIF.

Regards,

Nitin.

Read only

GauthamV
Active Contributor
0 Likes
1,367

SEARCH in SCN by Find Character in string you will get so many posts like these.

[https://forums.sdn.sap.com/click.jspa?searchID=19575500&messageID=6056291]

Read only

Former Member
0 Likes
1,367

Hi

data lv_string type string.

data ncount type i.

find ALL OCCURRENCES OF '~' in lv_string MATCH COUNT ncount.

ncount will have number of '~'.

Regards,

Rohit