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

check for values in variable

Former Member
0 Likes
1,866

hi

if am giving some value for a variable as input, i need to check if any particular letter is present in that or not how can i check that

for example if my input is 'ksjdfkaskdfj' i need to check whether 'a' is present in my input how do i do that using wat command

3 REPLIES 3
Read only

Former Member
0 Likes
1,303

data : v_str(25) value 'ksjdfkaskdfj'.

search v_str for 'a' .

if sy-subrc eq 0.

write : / 'character a is found'.

endif.

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,303

Hello Varalakshmi

You can simply use the <b>'CA'</b> (= contains any) operator, e.g.:

  TRANSLATE my_variable TO UPPER CASE. " if lower case is not relevant

  IF ( my_variable CA 'A' ).
    result = abap_true.  " = 'X'
  ELSE.
    result = abap_false. " = ' ' 
  ENDIF.

Regards

Uwe

Read only

Former Member
0 Likes
1,303

hey thanks for ur reply guys

now the requirement is if i dont specify the character but instead i need to search for any character in tht variable