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

Strings

Former Member
0 Likes
563

Hi Gurus,

How to find the no of alphabets,Upper case charecters, Lowercase charecters, numbers,special charecters in a given string ??

Thanks in advance,

Sriram.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
539

You have to find it using FIND statement and comparing with characters.

3 REPLIES 3
Read only

Former Member
0 Likes
540

You have to find it using FIND statement and comparing with characters.

Read only

Former Member
0 Likes
539

Hi,

DATA : v_string TYPE STRING value 'Ab1234Def',

v_num TYPE i,

v_chcnt TYPE i, " char count

v_nucnt TYPE i, " Number count.

v_spcnt TYPE I.

v_num = strlen( v_string ).

DO v_num TIMES.

IF v_string+0(1) CA SY-ABCDE.

v_chcnt = v_chcnt +1.

ELSEIF v_string+0(1) CA '0123456789'.

v_nucnt = v_nucnt + 1.

ELSEIF v_string+0(1) CA '~!@#$%^&*'.

v_spcnt = v_spcnt + 1.

ENDIF.

ENDDO.

Don't forget to reward if useful

Read only

Former Member
0 Likes
539

Hi,

I forgot add some more logic here.

DATA : v_string TYPE STRING value 'Ab1234Def',

v_num TYPE i,

v_chcnt TYPE i, " char count

v_nucnt TYPE i, " Number count.

v_spcnt TYPE I,

v_count TYPE i.

v_num = strlen( v_string ).

DO v_num TIMES.

v_count = v_count + 1.

IF v_string+0(v_count) CA SY-ABCDE.

v_chcnt = v_chcnt +1.

ELSEIF v_string+0(v_count) CA '0123456789'.

v_nucnt = v_nucnt + 1.

ELSEIF v_string+0(v_count) CA '~!@#$%^&*'.

v_spcnt = v_spcnt + 1.

ENDIF.

ENDDO.

Don't forget to reward if useful...