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

Former Member
0 Likes
346

hi

my requirement is i have to exculde the Z2 and Z5 in mstae field. is the follwing select query is correct,

please tell me how to use mstae ne z2 and z5 in one statement insted of using in following manner.

select matnr

mstae

from mara

into table gt_mara

where matnr EQ ms_matnr

and mstae ne 'Z2'

and mstae ne 'z5'.

2 REPLIES 2
Read only

Former Member
0 Likes
326

avoid using negative selects for performance reasons....

so proceed this way....

select matnr

mstae

from mara

into table gt_mara

where matnr EQ ms_matnr.

if sy-subrc = 0.

delete gt_mara where mstae = 'Z2' or mstae = 'Z5'.

endif.

Regards

Vasu

Read only

piyush_mathur
Active Participant
0 Likes
326

HI Hemal.

Please refer below piece of code

select matnr

mstae

from mara

into table gt_mara

where matnr EQ ms_matnr

and mstae not in ( 'Z2', 'z5').

Piyush

Reward points, if helpfull