Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Comparing Text

Former Member
0 Likes
2,078

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

1 ACCEPTED SOLUTION
Read only

Sm1tje
Active Contributor
0 Likes
1,266

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.

3 REPLIES 3
Read only

Former Member
0 Likes
1,266

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

Read only

Former Member
0 Likes
1,266

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

Read only

Sm1tje
Active Contributor
0 Likes
1,267

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.