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

performance in select statement

Former Member
0 Likes
1,110

Hi Everybody,

i had a small problem that

in selection screen iam gaetting company code,date as input for bsid-budat

i need to fetch data from bsid using company code and budat

But with condition:

If posting date (from parameter) is not blank.

Get all items with BSID-BUDAT less than or equal to “Posting Date”.

Else.

Do not filter by posting date.

Endif.

now how to write the select statement

select BUKRS KUNNR ZUONR GJAHR BELNR

FROM BSID

INTO TABLE ITAB

WHERE BUKRS IN S_BUKRS AND

BUDAT ..................... .

WHAT SHOULD BE THE ........

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,060

Hi,

Dont give the less than or equal condition in select query . fetch all records then filter data in itab. then performance will be good.

regards,

Nandha

Reward if it helps

9 REPLIES 9
Read only

Former Member
0 Likes
1,060
IF NOT P_BUDAT IS INITIAL.

select BUKRS KUNNR ZUONR GJAHR BELNR 
FROM BSID 
INTO TABLE ITAB
WHERE BUKRS IN S_BUKRS AND
BUDAT LE P_BUDAT.

ELSE.

 select BUKRS KUNNR ZUONR GJAHR BELNR 
FROM BSID 
INTO TABLE ITAB
WHERE BUKRS IN S_BUKRS.

ENDIF.
Read only

Former Member
0 Likes
1,060

Ur parameter screen is having Posting date as p_pdate.

select BUKRS KUNNR ZUONR GJAHR BELNR

FROM BSID

INTO TABLE ITAB

WHERE BUKRS IN S_BUKRS AND

BUDAT <=( or give LE) p_pdat.

Read only

Former Member
0 Likes
1,061

Hi,

Dont give the less than or equal condition in select query . fetch all records then filter data in itab. then performance will be good.

regards,

Nandha

Reward if it helps

Read only

Former Member
0 Likes
1,060

Hi,

the select shud be conditional :

if Posting date is not initial.

select BUKRS KUNNR ZUONR GJAHR BELNR

FROM BSID

INTO TABLE ITAB

WHERE BUKRS IN S_BUKRS AND

BUDAT LT Posting date .

else.

select BUKRS KUNNR ZUONR GJAHR BELNR

FROM BSID

INTO TABLE ITAB

WHERE BUKRS IN S_BUKRS.

endif.

Regards,

Himanshu

Read only

Former Member
0 Likes
1,060

hi Sunil

set Parameter as Mandatory (OBLIGATORY) then you no need to check its not blank ...

you must enter data otherwise your cant proceed

select *

into corresponding fields of <itab>

from BUDAT

where budat eq <date - parameter>

Rewards if useful.

Read only

Former Member
0 Likes
1,060

Hi sunil,

try this:

TABLES: BSID.

*

SELECT-OPTIONS: S_BUKRS FOR BSID-BUKRS.

PARAMETERS: P_BUDAT LIKE BSID-BUDAT.

*

IF NOT P_BUDAT IS INITIAL.

*

SELECT * FROM BSID WHERE BUKRS IN S_BUKRS

AND BUDAT LE P_BUDAT.

*

WRITE: / BSID-BUKRS, BSID-BUDAT.

*

ENDSELECT.

*

ENDIF.

Regards, Dieter

Read only

Former Member
0 Likes
1,060
IF P_DATE is not initial.
SELECT BUKRS KUNNR ZUONR GJAHR BELNR 
              FROM BSID 
               INTO TABLE ITAB
               WHERE BUKRS IN S_BUKRS 
                AND BUDAT LT P_DATE.

ELSE.
SELECT BUKRS KUNNR ZUONR GJAHR BELNR 
FROM BSID 
INTO TABLE ITAB
WHERE BUKRS IN S_BUKRS.

endif.
Read only

Former Member
0 Likes
1,060
IF P_DATE is not initial.
SELECT BUKRS KUNNR ZUONR GJAHR BELNR 
              FROM BSID 
               INTO TABLE ITAB
               WHERE BUKRS IN S_BUKRS 
                AND BUDAT LT P_DATE.

ELSE.
SELECT BUKRS KUNNR ZUONR GJAHR BELNR 
FROM BSID 
INTO TABLE ITAB
WHERE BUKRS IN S_BUKRS.

endif.
Read only

Former Member
0 Likes
1,060

keeping performance issue in mind.iam accessing the BSID without the BUDAT,later i will filter the data.

Thanks for all the guys replied for my query