09-20-2007 5:39 AM
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
09-20-2007 5:44 AM
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
09-20-2007 5:44 AM
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
09-20-2007 5:44 AM
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.
09-20-2007 5:45 AM
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.
09-20-2007 6:01 AM
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.
09-20-2007 6:17 AM
Hi Suresh,
I tried this way but cannot get the required output.
Line
09-20-2007 6:03 AM
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
09-20-2007 6:14 AM
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
09-20-2007 8:00 AM
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
09-20-2007 8:19 AM
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..