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 comparision in fields

Former Member
0 Likes
660

HI All,

I have a requirement to compare strings.

Like this:

     parameters:  belnr like bkpf-belnr.
     Select * from swwwihead into table t_swwwihead
        where ( WI_TYPE EQ 'F'   or
                WI_TYPE EQ 'W' ) AND
                WI_CD GE l_budat.
     X2 = belnr.
     Loop at t_swwwihead.
       X1 = t_swwwihead-TEXT.
       IF X1 byte-cs X2.
         write :/ t_swwwihead-TEXT.
       Endif.
     Endloop.

I tried to use 'CP' but i could not compare using fields. I mean i have to compare the values in the fields.

I tried byte-cs but that i can only compare in terms of bytes and my text doesnot have zeros at the begining. and xstring pads zeros to the string to make it a full byte it seems.

how can i compare this ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
628

Hi,

Try to concatenate * in the beginning and in the end of the to be compared string before using CP..

Example

-


data: X1 type string.

X1 = 'Approve Parked document 100638133 initiated by USER123'.

data: X2 type string.

X2 = '100638133'.

CONCATENATE '' X2 '' INTO X2.

IF X1 CP X2.

write: / 'True'.

ELSE.

write: / 'False'.

ENDIF.

Thanks,

Naren

Message was edited by: Narendran Muthukumaran

5 REPLIES 5
Read only

Former Member
0 Likes
628

Please give me an example of X1 and X2..

Thanks,

Naren

Read only

0 Likes
628

Thanks Narendran...!

X1 = Approve Parked document 100638133 initiated by USER123

and

X2 = 100638133

Read only

Former Member
0 Likes
629

Hi,

Try to concatenate * in the beginning and in the end of the to be compared string before using CP..

Example

-


data: X1 type string.

X1 = 'Approve Parked document 100638133 initiated by USER123'.

data: X2 type string.

X2 = '100638133'.

CONCATENATE '' X2 '' INTO X2.

IF X1 CP X2.

write: / 'True'.

ELSE.

write: / 'False'.

ENDIF.

Thanks,

Naren

Message was edited by: Narendran Muthukumaran

Read only

0 Likes
628

Thanks Naren.

It worked.

Read only

Former Member
0 Likes
628

Why not just use CS?

DATA: x1 TYPE string,
      x2 TYPE string.

x1 = 'Approve Parked document 100638133 initiated by USER123'.
x2 = '100638133'.

IF x1 CS x2.
* process
ENDIF.

Rob

Message was edited by: Rob Burbank