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

Regarding sql query

Former Member
0 Likes
435

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.

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
404

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

2 REPLIES 2
Read only

ThomasZloch
Active Contributor
0 Likes
405

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

Read only

Former Member
0 Likes
404

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