Skip to Content
author's profile photo Former Member
Former Member

select statement

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 04: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 04: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 05: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 07: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..

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.