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 text fields

Former Member
0 Likes
731

Hi,

I should compare two fields xblnr and belnr which have lenth 16 and 10 respectively. We should not reduce lenth of first field. Both are character type. Suggest me efficient way.

Regards,

Subbu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
668

Hi,

Can you use xblnr(10) EQ belnr?

3 REPLIES 3
Read only

franois_henrotte
Active Contributor
0 Likes
668

character fields are left-justified so you can just compare with "=" the first 10 digits of XBLNR and the field BELNR

Read only

Former Member
0 Likes
669

Hi,

Can you use xblnr(10) EQ belnr?

Read only

Former Member
0 Likes
668

hi

try using this:

CS (Contains String):

c1 contains the character string c2.

Trailing blanks in c1 and c2 are ignored if the respective field is of type C.

An empty string c2 (i.e., only blanks with type C, or empty string with type STRING) is included in any string c1, including the empty string itself. On the other hand, there is no non-empty string c2 included in an empty string c1.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of c2 in c1.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

The comparison is not case-sensitive.

Examples:

'ABCDE' CS 'CD' is true; SY-FDPOS = 2.

'ABCDE' CS 'XY' is false; SY-FDPOS = 5.

'ABAAA' CS 'AB ' is true; SY-FDPOS = 0.

' ABC' CS ' AB' is true; SY-FDPOS = 1.

'ABC DEF' CS ' ' is true; but: SY-FDPOS = 0,

since ' ' is interpreted as a trailing blank and is thus

ignored.

Regardsm

Prasant

*reward if helpful