‎2009 Nov 10 6:17 AM
Hi All,
I have a requirement like i need to compare two texts for example i need to retrieve the text from Purchase order as well from Purchase requisiton and i need to compare the both and if there is any difference i have update a flag. i am retrieving the texts from READ_TEXT function module.
Can any one suggest me some optimised way to compare the tex(If both the texts are same or different)??
Thanks in advance,
Joe
‎2009 Nov 10 7:07 AM
When using READ_TEXT function module, a table with all the 'lines' will be returned (tables parameter LINES). Compare the two internal tables and you will know, like this.
IF gt_lines1[] = gt_lines2[]. "gt_lines1 and 2 are internal tables per READ_TEXT.
* Same
ELSE.
*Different
ENDIF.
‎2009 Nov 10 6:27 AM
Hi
Check this FM MEDCMT_COMPARE_TEXTS
First translate them to UPPER CASE and then using an IF condition you can compare them .
Cheerz
Ram
‎2009 Nov 10 6:39 AM
Hi Joe,
You can use the below code snippet.
DATA: str1 TYPE string VALUE 'NiTesh',
str2 TYPE string VALUE 'Nitesh'.
DATA: lv_length1 TYPE i,
lv_length2 TYPE i,
lv_temp TYPE i VALUE 1.
lv_length1 = STRLEN( str1 ).
lv_length2 = STRLEN( str2 ).
IF lv_length1 EQ lv_length1.
DO lv_length1 TIMES.
IF str1+0(lv_temp) NE str2+0(lv_temp).
EXIT.
ELSE.
lv_temp = lv_temp + 1.
ENDIF.
ENDDO.
ENDIF.Thanks
Nitesh
‎2009 Nov 10 7:07 AM
When using READ_TEXT function module, a table with all the 'lines' will be returned (tables parameter LINES). Compare the two internal tables and you will know, like this.
IF gt_lines1[] = gt_lines2[]. "gt_lines1 and 2 are internal tables per READ_TEXT.
* Same
ELSE.
*Different
ENDIF.