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: 

Select querry with 'AND' and 'OR'

Former Member
0 Kudos

Hi,

I have a select querry need to execute on 'AND' and 'OR'

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND custodian EQ p_cust

AND bukrs EQ p_comp

AND clear EQ ' '.

1. case

will all the options mandatory

2. case

with or without custodian

3. case

with or without vendor

Can anyone please help me with this three querries.

Thanks

Fed

1 ACCEPTED SOLUTION

Former Member
0 Kudos

1. case- all options manadatory

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND custodian EQ p_cust

AND bukrs EQ p_comp

AND clear EQ ' '.

2. case with or without custodian

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND bukrs EQ p_comp

AND clear EQ ' '

OR custodian EQ p_cust.

3.case with or wothout vendor

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND bukrs EQ p_comp

AND custodian EQ p_cust.

AND clear EQ ' '

OR lifnr EQ so_lifnr.

<removed by moderator>

Edited by: Thomas Zloch on Jul 14, 2010 12:42 PM - please do not ask for ...

2 REPLIES 2

Sandeep_Kumar
Advisor
Advisor
0 Kudos

Use case based on your input:

e.g with or without custodian

if p_custodian is initial.

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND ( custodian EQ p_cust or custodian eq space)

AND bukrs EQ p_comp

AND clear EQ ' '.

endif.

Former Member
0 Kudos

1. case- all options manadatory

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND custodian EQ p_cust

AND bukrs EQ p_comp

AND clear EQ ' '.

2. case with or without custodian

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND lifnr EQ so_lifnr

AND bukrs EQ p_comp

AND clear EQ ' '

OR custodian EQ p_cust.

3.case with or wothout vendor

SELECT * FROM zcat3_mov

INTO CORRESPONDING FIELDS OF TABLE lt_getdata

WHERE invr_date IN so_date

AND bukrs EQ p_comp

AND custodian EQ p_cust.

AND clear EQ ' '

OR lifnr EQ so_lifnr.

<removed by moderator>

Edited by: Thomas Zloch on Jul 14, 2010 12:42 PM - please do not ask for ...