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

SELECT statement with CP operator

Former Member
0 Likes
14,214

Hello,

What is the correct statement to use CP operator in SELECT statement?

This does not work:

SELECT *

INTO CORRESPONDING FIELDS OF TABLE abc

FROM /abc/abc WHERE user CP some_var.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
7,626

Hi,

You can build a wildcard ranges and please try something like this.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B*'.

append r_wildcard.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B'.

append r_wildcard.

select * from mara

into table gt_mara_b

where mtart = 'YSAB'

and matnr in r_wildcard.

3 REPLIES 3
Read only

suresh_datti
Active Contributor
0 Likes
7,626

you'e to use LIKE for pattern searches ie

data some_var(8) value '%abcdef%'.

SELECT *

INTO CORRESPONDING FIELDS OF TABLE abc

FROM /abc/abc WHERE user LIKE some_var.

~SUresh

Read only

Former Member
7,627

Hi,

You can build a wildcard ranges and please try something like this.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B*'.

append r_wildcard.

r_wildcard-sign = 'I'.

r_wildcard-option = 'CP'.

r_wildcard-low = 'B'.

append r_wildcard.

select * from mara

into table gt_mara_b

where mtart = 'YSAB'

and matnr in r_wildcard.

Read only

Former Member
0 Likes
7,626

Hi,

Use LIKE Statement.

For more information

Hi,

CP (Contains Pattern)

The logical expression

<f1> CP <f2>

is true if <f1> matches the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:

for any character string: *

for any single character: +

Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.

If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify

characters in upper and lower case

the wildcard character "" (enter:#)

the wildcard character "" (enter: # )

the escape symbol itself (enter: ## )

blanks at the end of a string (enter: #___ )

Don't forget to reward if useful...