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

Standard function to find alphabet in string?

Former Member
0 Likes
5,176

Is there a standard function to find alphabet in string?

For example, a variable define as char (10),

I need a function to find out if this variable contains alphabet.

Any standard function there?

Is there a standard function to find alphabet in string?

For example, a variable define as char (10),

I need a function to find out if this variable contains alphabet.

Any standard function there?

19 REPLIES 19
Read only

JozsefSzikszai
Active Contributor
0 Likes
3,577

hi,

you don't need a function:

IF char CA sy-abcde.
==> it contains at least one letter
ELSE.
==> it does not contain any letter
ENDIF.

hope this helps

ec

Read only

Former Member
0 Likes
3,577

use-

DATA str(10).

if str CA sy-abcde.

"--> contains alphabet

else.

"--> does not contain alphabet

endif.

Regards,

Aparna Gaikwad

Read only

0 Likes
3,577

Thanks, I will try.

Read only

0 Likes
3,577

Thanks

Read only

Former Member
0 Likes
3,577

hiii

try using FM

DX_SEARCH_STRING

you can use logic like

len = strlen( wa_str ).
do.
   if ofset = len.
    exit.
  endif.
 if wa_string+ofset(1) co sy-abcde  .
      concatenate wa_string+ofset(1) into wa_final.

regards

twinkal

Read only

Former Member
0 Likes
3,577

Hi Lin,

Try the following:

parameters: p_char type c.

search sy-abcde for p_char.

if sy-subrc eq 0.
write: 'Found'.
else.
write: 'Not Found'.
endif.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
3,577

I tried use sy-abcde,but still can not get right result.

I think it only recognize Capital letter.

Edited by: lin tao on Sep 1, 2008 11:33 AM

Read only

0 Likes
3,577

just copy your code here, and explain what happens and what do you expect to happen...

Read only

0 Likes
3,577

Try this

take a variable and make its value as shown

v_abcde type char60 value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi...xyz'.

Now compare your variable suppose v_str as

If v_str CA v_abcde.

..

else.

..

Endif.

This will help!

Regards,

Prashant

Read only

0 Likes
3,577
I think it only recognize Capital letter.

post your code here.

Amit.

Read only

0 Likes
3,577

My code:

data: p_char(10) type c value'3001d0001'.

search sy-abcde for p_char.

if sy-subrc eq 0.

write: 'Found'.

else.

write: 'Not Found'.

endif.

if p_char CA sy-abcde.

write: 'Found'.

else.

write: 'Not Found'.

endif.

-


the output is Not found, Not found.

If I change value'3001D0001'

the output is Not found, found.

Read only

0 Likes
3,577

hii

use following code

data: wa_str(100) type c.
data: wa_str1 type string.
data: wa_str2 type string.
data: wa_str3 type string.


data: len type i.
data: ofset type i.

wa_str = 'ABCD7788HJK.
len = strlen( wa_str ).
do.
  if ofset = len.
    exit.
  endif.

 if wa_str+ofset(1) co sy-abcde  .
      concatenate wa_str2 wa_str+ofset(1) into wa_str2.
else.
    concatenate wa_str3 wa_str+ofset(1) into wa_str3.
  endif.

  ofset = ofset + 1.

enddo.
write:/ wa_str.
write:/ 'alphabate ::',  wa_str2.

regards

twinkal

Read only

0 Likes
3,577

I expect the program to recongnize both upper case and lower case letter. as long as the string contains any alph, it should ouput found.

Read only

0 Likes
3,577
data: p_char(10) type c value'3001d0001'.
TRANSLATE p_char TO UPPER CASE.
if p_char CA sy-abcde.


if sy-subrc eq 0.
write: 'Found'.
else.
write: 'Not Found'.
endif.
endif.

in both case of D and d i got the output found.

Amit.

Read only

Former Member
0 Likes
3,577

Hi lin,

You can use this code to check a variable.

IF VAR1 CA SY-ABCDE.

  • DO YOUR CALCULATION.

ENDIF.

<removed_by_moderator>

Edited by: Julius Bussche on Sep 1, 2008 10:06 AM

Read only

Former Member
0 Likes
3,577

Hi, maby it's not the full alfabeth but just some of it.

Then the CS 'ABCDE' (contain string) can be usefull.

/Tom

Read only

Former Member
0 Likes
3,577

hiii

use following code

data: wa_str(100) type c.
data: wa_str1 type string.
data: wa_str2 type string.
data: wa_str3 type string.


data: len type i.
data: ofset type i.

wa_str = 'ABCD435hjK'.
len = strlen( wa_str ).

TRANSLATE wa_str TO UPPER CASE.

do.
  if ofset = len.
    exit.
  endif.

 if wa_str+ofset(1) co sy-abcde  .
      concatenate wa_str2 wa_str+ofset(1) into wa_str2.
else.
    concatenate wa_str3 wa_str+ofset(1) into wa_str3.
  endif.

  ofset = ofset + 1.

enddo.


write:/ wa_str.
write:/ 'alphabatic char', 20 wa_str2.

here TRANSLATE wa_str TO UPPER CASE.

statement have added .i hope this will solve your problem.

regards

twinkal

Read only

Former Member
0 Likes
3,577

Hi,

Please ignore this.

Edited by: Syed Abdul Adil on Sep 1, 2008 12:31 PM

Read only

Former Member
0 Likes
3,577

Thank you for you all.

The problem is solved now.