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

string comparison

Former Member
0 Likes
601

Hello Experts,

how can I make string comparison very easily e.f. if there is a char40 field .

Thx in advance

ertas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
566

Hi

You can us something like:


DATA: f1(25) TYPE c VALUE 'shital ABAP',

      f2(25) TYPE c VALUE 'shital ABAP'.

IF f1 EQ f2.
   WRITE: /  'True'.
ELSE.
   WRITE: /  'False'.
ENDIF.
.

Refer [this|http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3516358411d1829f0000e829fbfe/content.htm] for understand how comparisons happen.

Also note that comparisons are case sensitive.

Regards

Shital

Edited by: shital phadake on May 10, 2009 5:36 PM

4 REPLIES 4
Read only

faisalatsap
Active Contributor
0 Likes
566

Hi, Ertas

Can you Please Explain your Requirement with Example so that we will be able to help accordingly. I think Requirements are not clear.

Regards,

Faisal

Read only

Former Member
0 Likes
566

just comparing 2 decription fields.

field1-description = 'the live is great'

field2-description = ''the live is boring.

How can you compare both string very reliable

Read only

0 Likes
566

Hi, Ertas

You Need following? sorry still not very clear

DATA: str1(40) VALUE 'SDN',
      str2(40) VALUE 'SDn'.

IF str1 = str2.
  WRITE: 'Strings are Equal'.
ELSE.
  WRITE: 'Strings are not Equal'.
ENDIF.

Regards,

Faisal

Read only

Former Member
0 Likes
567

Hi

You can us something like:


DATA: f1(25) TYPE c VALUE 'shital ABAP',

      f2(25) TYPE c VALUE 'shital ABAP'.

IF f1 EQ f2.
   WRITE: /  'True'.
ELSE.
   WRITE: /  'False'.
ENDIF.
.

Refer [this|http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3516358411d1829f0000e829fbfe/content.htm] for understand how comparisons happen.

Also note that comparisons are case sensitive.

Regards

Shital

Edited by: shital phadake on May 10, 2009 5:36 PM