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 statement

Former Member
0 Kudos

Hi Guys,

Whats wrong in my select statement.,

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' )

OR ( invr_date GE so_date-low and

invr_date LE so_date-high ).

Here I need to pick only records where the data in between so_date-low and so_date-high, but with this select statement it is picking all the records.,

Can and one tell me how to do it.,

Regards,

Line

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Line ,

What all condition you want to check , because in this case if a record satisfies any of the condition

1. status EQ 'CL' AND bukrs EQ p_ccode

2. lifnr EQ p_vendor OR lifnr EQ ' '

3. invr_date GE so_date-low and invr_date LE so_date-high

then the record will be selected , now if what you want is the the date range must be in the so_date range then the condition must not be OR but AND , so that for every record that is selected this condition must be satisfied.

Regards

Arun

9 REPLIES 9

Former Member
0 Kudos

Hi Line ,

What all condition you want to check , because in this case if a record satisfies any of the condition

1. status EQ 'CL' AND bukrs EQ p_ccode

2. lifnr EQ p_vendor OR lifnr EQ ' '

3. invr_date GE so_date-low and invr_date LE so_date-high

then the record will be selected , now if what you want is the the date range must be in the so_date range then the condition must not be OR but AND , so that for every record that is selected this condition must be satisfied.

Regards

Arun

Former Member
0 Kudos

Hi,

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' ) -


> <b>Here comes the mistake</b>

OR ( invr_date GE so_date-low and

invr_date LE so_date-high ).

Use

<i>SELECT ... WHERE <s> IN (<f 1>, ......, <f n>) ...</i>

Please reward if useful.

Former Member
0 Kudos

Hi line,

try this:

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' )

<b>AND invr_date IN so_date.</b>

Regards,

Sachin.

Former Member
0 Kudos

hi,

invr_date is select options then try like this

data: so_date like sy-datum [use appropriate table and field for this]

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' )

OR ( invr_date in so_date.)

if it displays all records means then ur condition is failing and after select check sy-subrc value by if and proceedd further or debug it.

if helpful reward some points.

with regards,

Suresh Aluri.

0 Kudos

Hi Suresh,

I tried this way but cannot get the required output.

Line

Former Member
0 Kudos

hi,

i changed last line of ur sele3ct query please check...

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' )

OR ( invr_date GE so_date-low and

invr_date in so_date.

thanks,

maheedhar

Former Member
0 Kudos

Dear,,

try this: SURELY RESOLVED.

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

AND (lifnr EQ p_vendor OR lifnr EQ ' ' )

AND invr_date IN so_date.

CHEERS !!

REGARDS

AMIT SINGLA

Former Member
0 Kudos

hi,

try this

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

AND ( invr_date GE so_date-low and invr_date LE so_date-high )

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' ).

thanks

Dharmishta

Former Member
0 Kudos

hi line,

since u need data only in between the dates in so_date you need to put an and condition instead of or.also instead of taking the so_date-low and so_date-high you can use "IN" to get the range.

SELECT lifnr

xblnr

bukrs

inv_date

invr_date

zterm

dmbtr

waers

kursf

status FROM zinv_reg INTO TABLE lt_reg

WHERE status EQ 'CL'

AND bukrs EQ p_ccode

OR ( lifnr EQ p_vendor OR lifnr EQ ' ' )

and ( invr_date in so_date).

Regards,

Sohi..