‎2006 Jan 20 6:27 PM
Hi all,
i have 2 strings one with 15 characters(string1) and the other one can have up to 15 characters(string2).
Im trying to figure out how i can check if string2 contains the letters of string1 and as soon as it finds a letter that does not match it sends an error.
However, the characters in the string2 can be in different order.
Thanks in advance!
‎2006 Jan 20 6:36 PM
Couple different ways to do this. Here is one solution.
report zrich_0003.
data: string1 type string.
data: string2 type string.
data: offset type i.
data: length type i.
string1 = 'ABCDEFGHI'.
string2 = 'IHGFXEDCBA'.
length = strlen( string2 ).
while sy-subrc = 0.
if offset => length.
exit.
endif.
search string1 for string2+offset(1).
if sy-subrc <> 0.
message e001(00) with 'Value not found in string1'.
endif.
offset = offset + 1.
endwhile.
Regards,
Rich Heilman
‎2006 Jan 20 6:36 PM
Couple different ways to do this. Here is one solution.
report zrich_0003.
data: string1 type string.
data: string2 type string.
data: offset type i.
data: length type i.
string1 = 'ABCDEFGHI'.
string2 = 'IHGFXEDCBA'.
length = strlen( string2 ).
while sy-subrc = 0.
if offset => length.
exit.
endif.
search string1 for string2+offset(1).
if sy-subrc <> 0.
message e001(00) with 'Value not found in string1'.
endif.
offset = offset + 1.
endwhile.
Regards,
Rich Heilman