Skip to Content
avatar image
Former Member

Standard function to find alphabet in string?

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

10 Answers

  • Sep 01, 2008 at 08:58 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:00 AM

    use-

    DATA str(10).

    if str CA sy-abcde.

    "--> contains alphabet

    else.

    "--> does not contain alphabet

    endif.

    Regards,

    Aparna Gaikwad

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:02 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:09 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:28 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • avatar image
    Former Member
    Sep 01, 2008 at 09:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:59 AM

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

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

    /Tom

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 10:12 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 10:13 AM

    Hi,

    Please ignore this.

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 01:08 PM

    Thank you for you all.

    The problem is solved now.

    Add comment
    10|10000 characters needed characters exceeded