Application Development 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: 

Standard function to find alphabet in string?

Former Member
0 Kudos
2,154

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

JozsefSzikszai
Active Contributor
0 Kudos
555

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

Former Member
0 Kudos
555

use-

DATA str(10).

if str CA sy-abcde.

"--> contains alphabet

else.

"--> does not contain alphabet

endif.

Regards,

Aparna Gaikwad

0 Kudos
555

Thanks, I will try.

0 Kudos
555

Thanks

Former Member
0 Kudos
555

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

Former Member
0 Kudos
555

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

Former Member
0 Kudos
555

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

0 Kudos
555

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

0 Kudos
555

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

0 Kudos
555
I think it only recognize Capital letter.

post your code here.

Amit.

0 Kudos
555

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.

0 Kudos
555

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

0 Kudos
555

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.

0 Kudos
555
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.

Former Member
0 Kudos
555

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

Former Member
0 Kudos
555

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

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

/Tom

Former Member
0 Kudos
555

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

former_member705122
Active Contributor
0 Kudos
555

Hi,

Please ignore this.

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

Former Member
0 Kudos
555

Thank you for you all.

The problem is solved now.