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

Issue with 'Where' Condition

Former Member
0 Likes
595

Hi All,

We have used the following code in our report.

I would like to know what is the logic behind using this type of where condition.....????

SELECT PERNR

KST01

BEGDA

ENDDA FROM PA0027 INTO CORRESPONDING FIELDS OF TABLE IT_PA0027

FOR ALL ENTRIES IN IT_KOSTL

WHERE KST01 = IT_KOSTL-KOSTL

AND ( ( BEGDA <= P_DATE1 AND ENDDA >= P_DATE2 )

OR ( BEGDA >= P_DATE1 AND BEGDA <= P_DATE2 )

OR ( ENDDA >= P_DATE1 AND ENDDA <= P_DATE2 ) ) .

In our selection screen, we have Two dates called Start Date and End Date (Both have no range...they are parameters).

From Date: P_DATE1

To Date: P_DATE2

Can anyone explain me, whats the meaning of above where condition...???

Regards

Pavan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
568

hi,

( BEGDA <= P_DATE1 AND ENDDA >= P_DATE2 )

-- it checks if begin date falls earlier or on the same day of p_date1 and p_date2 is on or after end date

( BEGDA >= P_DATE1 AND BEGDA <= P_DATE2 )

-- if begin date is between p_date1 and p_date2

( ENDDA >= P_DATE1 AND ENDDA <= P_DATE2 ) )

-- end date is between p_date1 and p_date2

either one condition is satisfied a record is picked.

regards,

madhu

Hi All,

We have used the following code in our report.

I would like to know what is the logic behind using this type of where condition.....????

SELECT PERNR

KST01

BEGDA

ENDDA FROM PA0027 INTO CORRESPONDING FIELDS OF TABLE IT_PA0027

FOR ALL ENTRIES IN IT_KOSTL

WHERE KST01 = IT_KOSTL-KOSTL

AND ( ( BEGDA <= P_DATE1 AND ENDDA >= P_DATE2 )

OR ( BEGDA >= P_DATE1 AND BEGDA <= P_DATE2 )

OR ( ENDDA >= P_DATE1 AND ENDDA <= P_DATE2 ) ) .

In our selection screen, we have Two dates called Start Date and End Date (Both have no range...they are parameters).

From Date: P_DATE1

To Date: P_DATE2

Can anyone explain me, whats the meaning of above where condition...???

Regards

Pavan

3 REPLIES 3
Read only

Former Member
0 Likes
569

hi,

( BEGDA <= P_DATE1 AND ENDDA >= P_DATE2 )

-- it checks if begin date falls earlier or on the same day of p_date1 and p_date2 is on or after end date

( BEGDA >= P_DATE1 AND BEGDA <= P_DATE2 )

-- if begin date is between p_date1 and p_date2

( ENDDA >= P_DATE1 AND ENDDA <= P_DATE2 ) )

-- end date is between p_date1 and p_date2

either one condition is satisfied a record is picked.

regards,

madhu

Read only

Former Member
0 Likes
568

hi here the condition is using the three set of values..for the start date and the end date for the records fetching..

1. if the start date is equal to less than the p_date1 and the end date is greate than or equla to the p_date2 means ...this means the select fetches all the records which includes the time interval...from p_date1 to p_date2 .

regards,

venkat

Read only

Former Member
0 Likes
568

Make sure parameter field is manatory if no input is given in the parameter field no record will be selected.

Regards

Bikas