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

Character strings comparision

Former Member
0 Likes
432

Hi,

How could we compare two <u>character strings</u> having different size.

ex: name1(5)

name2(30).

name2 is a sap table field , but it stores data from user up to 5 characters only, i cann't modify name2 filed,

I am using

If (name1 = name2)

.....

else.

....

endif.

Is it good practice.

Please let me know ur good suggestions.

Thanks.

Rao.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
414

Change your logic as follows:

If ( name1 = name2<b>+0(5)</b> ). "Means the first 5 characters only.

.....

else.

....

endif.

Regards,

Ravi

3 REPLIES 3
Read only

Former Member
0 Likes
415

Change your logic as follows:

If ( name1 = name2<b>+0(5)</b> ). "Means the first 5 characters only.

.....

else.

....

endif.

Regards,

Ravi

Read only

0 Likes
414

Thanks to Ravi & Chandu.

regards.

Rao.

Read only

Former Member
0 Likes
414
report ychatest line-size 350.

data : name1(5) value 'CHAND',
       name2(30) value 'CHANDRASEKHAR'.

if name1 eq name2+0(5).
  write : 'OK'.
else.
  write : 'NOT OK'.
endif.