04-16-2008 12:52 PM
Hi,
some one help me in findind the string difference
I have a req like this,
'test my object'
'test my dev object'
so with the help of some keyword, I want to find the difference result as 'dev'.
can you please help me?
04-16-2008 12:57 PM
do this way ..
report ztest.
data: string1 type string,
string2 type string.
string1 = 'G3430-60'.
string2 = 'G3430-60123'.
search string2 for string1.
if sy-subrc = 0.
replace string1 with space into string2.
condense string2.
endif.
write:/ string2.
04-16-2008 12:59 PM
hi check this...
syntax : DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO dst IN {BYTE|CHARACTER} MODE.
DATA: BEGIN OF struc,
comp1 TYPE i,
comp2(1) TYPE x,
comp3(4) TYPE c VALUE 'Hey',
comp4(4) TYPE c VALUE 'you!',
comp5 TYPE x,
END OF struc.
DATA: off TYPE i,
len TYPE i.
FIELD-SYMBOLS: <hex> TYPE x,
<result> TYPE c.
DESCRIBE DISTANCE BETWEEN:
struc AND struc-comp3 INTO off IN BYTE MODE,
struc-comp3 AND struc-comp5 INTO len IN BYTE MODE.
regards,
venkat.
04-16-2008 1:02 PM
Hi,
do something like this.
data: itab type table of string.
data: begin of itab1 occurs 0,
value type string,
end of itab1.
data: begin of itab2 occurs 0,
value type string,
end of itab2.
split sent1 into table itab.
loop at itab.
move itab to itab1-value.
appenend itab1.
endloop.
refresh itab.
split sent2 into table itab.
loop at itab.
move itab to itab2-value.
append itab2.
endloop.
loop at itab2.
read table itab1 with key value = itab2-value.
if sy-subrc <> 0.
write:/ itab2-value.
endif.
endloop.
REgards,
Ravi Kanth
04-16-2008 1:11 PM
this worked
DATA: string1 TYPE string,
string2 TYPE string.
DATA:
BEGIN OF it_words OCCURS 0,
word(50),
END OF it_words.
DATA:
BEGIN OF it_words2 OCCURS 0,
word(50),
END OF it_words2.
string1 = 'test my object'.
string2 = 'test my dev object'.
SPLIT string1 at space into TABLE it_words.
SPLIT string2 at space into TABLE it_words2.
LOOP AT it_words2.
READ table it_words WITH KEY word = it_words2-word.
IF sy-subrc EQ 0.
DELETE it_words2.
ENDIF.
ENDLOOP.
LOOP AT it_words2.
WRITE:/ it_words2-word.
ENDLOOP.
04-16-2008 1:16 PM
Hi,
I dont have exactly how to get the diff word, I just have an idea which may help you.
Ex: s1 have value test my object
S2 = test my dev objects.
If s2 co s1.
Here it checks s2 contains only s1 or not.
If s2 have some thing different than s1, then sy-fdpos stores the offset of the string from where the s2 is differing from s1.
Hope it may help you.
Reward if helpful.