‎2009 Nov 03 12:55 PM
Hi Guriji,s
I have written one query in which i want to fetch the data between some dates. but when we execute this query it will fetch the data from starting of the date.Plz tell me what is the problem in my query.
In the initial input screen we are giving the material no. Plant And Days.
Based on the days we are calculating the date.
Tables: WB2_V_MKPF_MSEG2.
IF DAYS IS NOT INITIAL.
WB2_V_MKPF_MSEG2-BUDAT = ( SY-DATUM - DAYS ).
SELECT MATNR_I WERKS_I BWART_I BUDAT FROM WB2_V_MKPF_MSEG2 INTO CORRESPONDING FIELDS OF TABLE T_ITAB4
WHERE WERKS_I IN PLANT and matnr_I in Material AND BWART_I = '201' or BWART_I = '261'AND BUDAT BETWEEN WB2_V_MKPF_MSEG2-BUDAT AND SY-DATUM .
ENDIF.
thanks.
‎2009 Nov 03 1:25 PM
Try including some brackets and see if it helps
... AND ( BWART_I = '201' or BWART_I = '261' ) AND ...and please use more meaningful subject lines in the future.
Thomas
‎2009 Nov 03 1:25 PM
Try including some brackets and see if it helps
... AND ( BWART_I = '201' or BWART_I = '261' ) AND ...and please use more meaningful subject lines in the future.
Thomas
‎2009 Nov 03 1:31 PM
Hello,
The problem is with the bracket.Thomas is correct.
The program is not evaluating all select conditions.if the condition "WERKS_I IN PLANT and matnr_I in Material AND BWART_I = '201' "is true it will not check for the date condition because that is added with OR part.So put the bracket as told by thomas.
In case OR,if any of the condition is true it will not evaluate the 2nd part
Regards,
Shweta