‎2009 May 29 10:33 AM
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?
‎2009 May 29 10:37 AM
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.
‎2009 May 29 10:41 AM
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?
‎2009 May 29 10:42 AM
‎2009 May 29 10:46 AM
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.
‎2009 May 29 10:58 AM
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
‎2009 May 29 10:39 AM
‎2009 May 29 10:44 AM
‎2009 May 29 10:44 AM
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
‎2009 May 29 10:45 AM
DATA: w_var TYPE BKPF-BKTXT.
W_VAR = 'SWASTIKROCKS'.
FIND REGEX 'ROCKS\>' IN W_VAR.
WRITE sy-subrc.
‎2009 May 29 10:46 AM
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
‎2009 May 29 10:54 AM
see... use search
search str for '*sh'.
if sy-subrc = 0 => ur search is successful finding sh at the end of str.
‎2009 May 29 10:51 AM
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