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

String operation symbol

Former Member
0 Likes
1,571

Hi All,

Can anybody let me know the symbol used for searching any string ending with a particular character/string"?

Suppose if a string contains required string then we use 'ca'. like that if want to know at the end?

12 REPLIES 12
Read only

Former Member
0 Likes
1,510

Hi shruti,

can you please elobrate your question.

There are many such operators used to find a particular string;

CO: Contains only.

CN: Contaisn not only

CA: Contains Any

NA: Contains not any

CS: Contains String.

NS: Contains No string.

CP: Contains Pattern.

NP: Contains No Pattern.

Regards,

Nikhil.

Read only

0 Likes
1,510

I have variable which stores strings in it.

If that variable ends with 'sh' then i need to perform some other actions..

So can you please tell me what symbol i can use in the if conditon?

Read only

0 Likes
1,510

No such string operation is available

Regards

Lalit

Read only

0 Likes
1,510

Hi Shruti,

You can use this type of logic

loop at itab.

if itab-fieldname CA 'ABCDEFGHIJKLMONQRSTUVWXYZ0123456789+-*/$@^&()<>&~.!'.
replace all occurrences of 'sh' in itab-fieldname with space.
write: / itab-fieldname.
endif.
endloop.

Read only

0 Likes
1,510

You can write like below

data: v_length type i.

data: v_length1 type i.

v_length = v_yourvar "String length of your variable.

v_length1 = v_length - 2.

if v_yourvar+v_length1(2) = 'SH'

"Your Code

endif.

Regards

Lalit

Read only

Former Member
0 Likes
1,510

Hi Shruti,

you can use CA.

Thanks,

Manas

Read only

Former Member
0 Likes
1,510

Hi,

TRy to use CO and CA. May be helpful.

Read only

former_member222860
Active Contributor
0 Likes
1,510

You can do like this to find the last char of the string:

data: v_str type string.
data: v_str1 type string.
data: len type i.

v_str = 'MAHESH$'.

len = strlen( v_str ).

len = len - 1.

v_str1 = v_str+len(1).

write:/ v_str1.

Mahesh

Read only

Former Member
0 Likes
1,510

DATA: w_var TYPE BKPF-BKTXT.
W_VAR = 'SWASTIKROCKS'.
FIND REGEX 'ROCKS\>' IN W_VAR.
WRITE  sy-subrc.
Read only

Former Member
0 Likes
1,510

Hi,

There is no symbol as such. What you need to do is read the last 2 character and check if it is 'sh'.

Data: v_var type string value 'asdfdfdfdgfgfsh',

v_len type i.

v_len = strlen( v_var ).

v_len = v_len - 2.

if v_var+len(2) = 'sh'.

else.

endif.

Regards,

Nikhil

Read only

0 Likes
1,510

see... use search

search str for '*sh'.

if sy-subrc = 0 => ur search is successful finding sh at the end of str.

Read only

Former Member
0 Likes
1,510

Hi

u can achieve the same by a logic. Suppose the last 2 characters u want to test,then:

data: str type string value 'sajid'.

data: str1 type string.

data: var_i type i.

*get the string length.

var_i = strlen( str ).

*subtract 2 from the length

var_i = var_i - 2.

*get the last two characters into str1 and u can check the str1.

str1 = str+var_i(2).

Regards

Sajid