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

Compare 2 String Values and Count How Many Chars Are Different

Former Member
0 Likes
670

Dear All,

I need to compare 2 string fields, which contain names, and count how many different characters there are. If there are more than 3 different characters that line will be marked 'X'. For example;

NAME: JAKC BAUE

CHANGED NAME: JACK BAUER

Here there are 3 different characters so;

FLAG = 'X'.

NAME: ACK BOUER

CHANGED NAME: JACK BAUER

FLAG = ' '

I discussed with an ABAP developer and we could not find an exact solution because the first name field is usually entered by mistake and the second one contains the fixed name. That s why there are so many cases.

Calculating length differences work for some cases but not all, also 'CP' doesnt cover all the cases so I decided to ask for other opinions. Please feel free to write down your suggestions.

Regards,

Merih

Dear All,

I need to compare 2 string fields, which contain names, and count how many different characters there are. If there are more than 3 different characters that line will be marked 'X'. For example;

NAME: JAKC BAUE

CHANGED NAME: JACK BAUER

Here there are 3 different characters so;

FLAG = 'X'.

NAME: ACK BOUER

CHANGED NAME: JACK BAUER

FLAG = ' '

I discussed with an ABAP developer and we could not find an exact solution because the first name field is usually entered by mistake and the second one contains the fixed name. That s why there are so many cases.

Calculating length differences work for some cases but not all, also 'CP' doesnt cover all the cases so I decided to ask for other opinions. Please feel free to write down your suggestions.

Regards,

Merih

1 REPLY 1
Read only

Former Member
0 Likes
476

Maybe the distance function will help you to reach your goal.

http://help.sap.com/abapdocu_702/en/abendistance_functions.htm

It computes the Levenshtein distance of two strings.

Regards,

Thomas