‎2009 Feb 10 5:19 AM
hii,
i want to match a field's substring
like
field
ABC,
ABD,
ABE
here first two char r constant.
‎2009 Feb 10 5:22 AM
hi,
Check this..
DATA: str1 TYPE string,
str2 TYPE string.
str1 = 'ABCDEFGH'.
str2 = '*ABC'.
IF str1 CS str2.
WRITE : str1, 'Conatins', str2.
ENDIF.
Contains String: True if the content of operand2 is contained in operand1. Upper/lower case is not taken
into account, trailing blanks of the left operand are taken into account. If operand1 is of type string and
initial, or of type c and contains only blank characters, the logical expression is false, unless operand2
is also of type string and initial, or of type c and only contains blank characters. In this case the logical
expression is always true. If the result of the comparison is true, sy-fdpos contains the offset of
operand2 in operand1. If the result of the comparison is negative, sy-fdpos contains the length of
operand1.Edited by: Avinash Kodarapu on Feb 10, 2009 10:52 AM
‎2009 Feb 10 5:21 AM
Hi Akshaya,
Welcome to Our Forum.
Can you explain your requirement briefly.
Thanks.
‎2009 Feb 10 5:24 AM
‎2009 Feb 10 5:22 AM
hi,
Check this..
DATA: str1 TYPE string,
str2 TYPE string.
str1 = 'ABCDEFGH'.
str2 = '*ABC'.
IF str1 CS str2.
WRITE : str1, 'Conatins', str2.
ENDIF.
Contains String: True if the content of operand2 is contained in operand1. Upper/lower case is not taken
into account, trailing blanks of the left operand are taken into account. If operand1 is of type string and
initial, or of type c and contains only blank characters, the logical expression is false, unless operand2
is also of type string and initial, or of type c and only contains blank characters. In this case the logical
expression is always true. If the result of the comparison is true, sy-fdpos contains the offset of
operand2 in operand1. If the result of the comparison is negative, sy-fdpos contains the length of
operand1.Edited by: Avinash Kodarapu on Feb 10, 2009 10:52 AM
‎2009 Feb 10 5:23 AM
Hi Akshaya
lv_a = ABC.
lv_b = ABD.
then we can compare them like
IF lv_a(2) = lv_b(2). "lv_a(2) = 'AB' = lv_b(2)
Pushpraj
‎2009 Feb 10 5:24 AM
Hi
Welcome to SDN
you can use offsets and compare them
Thanks
Viquar Iqbal
‎2009 Feb 10 5:25 AM
Hi Akshaya,
Try using offset because you are using Character strings.
like here in your case ABC and ABD are there.
So you can try it out like,
w_string0(2) = w_string10(2).
or if you want the 2nd and 3rd characters you can increment your offset like .
w_string+W_count(w_count1).
w_count = w+count + 1.
w_count1 = w_count1 + 1 .
Try using this logic hope it helps!
Much Regards,
Amuktha.
‎2009 Feb 10 5:29 AM
hi,
DATA:
counter TYPE i value '5',
fl_flag,
str1 TYPE char12 VALUE 'good morning',
str2 TYPE char12 VALUE 'good morning'.
DO counter TIMES.
IF str1(sy-index) = str2(sy-index).
fl_flag = 'X'.
ELSE.
EXIT.
ENDIF.
ENDDO.
IF fl_flag = 'X'.
WRITE:
'letter to letter mapped'.
ENDIF.
In the counter variable mention the position till where you want to check the strings.
Thanks
Sharath