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
909

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
Read only

Former Member
0 Likes
877

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
Read only

Former Member
0 Likes
878

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

Read only

Former Member
0 Likes
877

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.

Read only

Former Member
0 Likes
877

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.

Read only

Former Member
0 Likes
877

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.

Read only

0 Likes
877

Hi Suresh,

I tried this way but cannot get the required output.

Line

Read only

Former Member
0 Likes
877

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

Read only

Former Member
0 Likes
877

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

Read only

Former Member
0 Likes
877

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

Read only

Former Member
0 Likes
877

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..