Application Development 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: 

relacement of NP relational operator in select queries

Former Member
0 Kudos

     Dear experts,

i would like to select the entries from a table which do not start with 'y' or 'z' as the relation operators are not allowed in select queries please help me on how should i achieve the my desired result.

my sample code is as follows(which of course has an error).

select tabname from dd02l into table itab

         where clidep = ' '

         and tabname np y*

          or taname np z*.

i know the above code is incorrect but hope u understand my requirement.

thanks and regards,

Abdullah.

1 ACCEPTED SOLUTION

naveenvishal
Contributor
0 Kudos

Hi Abdullah,

you can give statement like

SELECT tabname from dd02l into table itab

WHERE ( FN1 NOT LIKE 'y%')

AND ( FN1 NOT LIKE 'z%')

Hope this helps.

Regards,

Naveen

6 REPLIES 6

naveenvishal
Contributor
0 Kudos

Hi Abdullah,

you can give statement like

SELECT tabname from dd02l into table itab

WHERE ( FN1 NOT LIKE 'y%')

AND ( FN1 NOT LIKE 'z%')

Hope this helps.

Regards,

Naveen

0 Kudos

HI Naveen,

Thanks for your reply and i got the answer with some trial and errors. any ways i would like to correct you you should the letters in capital inside the quotes only then the select query will provide you the desired results.

Thanks and Regards,

Abdullah.

Former Member
0 Kudos

Hi,

you can try to implement your SELECT-statement like that:

SELECT tabname FROM dd02l INTO TABLE itab WHERE tabname NOT LIKE 'y%' AND tabname NOT LIKE 'z%' .


That should work!


If it work, please mark as correct answer.

0 Kudos

HI Alexander,

Thanks for the reply.

Regards,

Abdullah.

raymond_giuseppi
Active Contributor
0 Kudos

Well you cannot use the same syntax for database where clause than for string coimparison operatore (too sad ?)

Except... if you use IN range option in the statement.

CLEAR so_fm1.
so_fm1-sign = 'E'. " exclude
so_fm1-option = 'CP'. " contain pattern
so_fm1-low = 'Y*'.
APPEND so_fm1.
so_fm1-low = 'Z*'.
APPEND so_fm1.
* ...
   WHERE fm1 IN so_fm1.

NB: Actually the generated SQL statement will contain some NOT LIKE 'Y%' clauses.

Regards,
Raymond

0 Kudos

Hi Raymond,

Thanks for the reply. i got it thank you.

Regards,

Abdullah.