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

cp operator in select statement

Former Member
0 Likes
19,468

Hi i am getting error when i write the below select statement, could any one please let me know, how to use  CP operator in select statement

my code was

SELECT lifnr name1 FROM lfa1 INTO CORRESPONDING

        FIELDS OF TABLE lt_lfa1 

        WHERE lifnr CP lv_lifnr AND

              name1 CP  lv_name1.

Thanks

Srini

Message was edited by: Manish Kumar <spoonfeeding, thread locked by moderator>

Message was edited by: Manish Kumar

9 REPLIES 9
Read only

PeterJonker
Active Contributor
0 Likes
10,294

You need to use WHERE lifnr LIKE lv_lifnr and in lv_lifnr you should have concatenated the existing value (lets say it is 10003) so it will be %10003%.

Check the help function on LIKE.

Read only

Former Member
0 Likes
10,294

You can't use the operator in select query, instead declare as range and fill the range with option = CP

Read only

SimoneMilesi
Active Contributor
0 Likes
10,294

CP is not allowed as select operator.

You shoul declare select-options/ranges and fill them with I - CP -low_value

Read only

Former Member
0 Likes
10,294

either you have select-options with lifnr and name and use them in the below query as

SELECT lifnr name1 FROM lfa1 INTO CORRESPONDING

        FIELDS OF TABLE lt_lfa1 

        WHERE lifnr in s_lifnr AND

              name1 in s_name1.


else you need to declare internal tables with structure as below..

DATA: begin of ls_user1,
    sign type c,
    option(2) type c,
    low(90) type c,
    high(90) type c,
   end of ls_user1.


data: lt_lifnr like ls_user1 occurs 0,

         lt_name1 like ls_user1 occurs 0.

and then populate these as

ls_user1-sign = 'I'.

ls_user1-option = 'CP'.

ls_user1-low = '*'.  populate with whatever pattern you want

APPEND ls_user1 TO lt_lifnr


similarly do it for NAME1 and use them in the query.

Read only

Former Member
0 Likes
10,294

Hi  friends

i am sorry my actual requirement is

if user  enters   'su*'. in NAME FIELD

it should fetch all the records with  'su'   in case insesitive

could any one please let me know how to solve this

Thanks

Srini

Read only

0 Likes
10,294

See my answer. You need to concatenate % in front and after the user input and then use LIKE in your where statement.

Read only

0 Likes
10,294

hi peter

i used like operator

but when i enter 'su'.

i am not getting name   'Suresh'

when users enters 'su*'

it should fetch Suresh also

Read only

0 Likes
10,294

hi peter

if we user LIKE operator its case sensitive

but want to fetch records   with case insensitive

is there any other option , pls let me know

Read only

0 Likes
10,294

Since it's LFA1-NAME1 is case sensitive, you have to manage all the options possible

It's already been debated long time (a little search on SDN)

Here previous posts

https://www.google.it/search?q=abap+case+sensitive+select+site:scn.sap.com&biw=1366&bih=667&gws_rd=s...

Here a smart solution even if performances can be a problem

select the text from lower case data element - ABAP Development - SCN Wiki