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

select queries

Former Member
0 Likes
990

Hi ,

when using select query like

Select VDATU BDATU LIFNR NOTKZ from EORD into table IT_EORD

where MATNR = WA_FINAL-MATNR

And WERKS = WA_FINAL-WERKS.

is it is mandatory to keep all key fields in where condition.

IS above query is correct(performance wise).Because in EORD key fields are MATNR,

WERKS,ZEORD.

In which case it's mandatory to keep all key fields in where condition.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
950

Hi,

The Select query is fine, it is not mandatory to include all the key fields in the where clause, it all depends on the requirements.

Yes, putting all the key fields in the where clause will definitely help to fetch data faster. Since system has to less check for data, it can directly go keeping all the key fields as search criteria.

Thanks & Regards,

Navneeth K.

7 REPLIES 7
Read only

Former Member
0 Likes
950

Hi Boss,

TO improve the performance of the program in select querey the key fields are must and should in the where condition.

Best Regards,

Narasimha Rao.

Read only

Former Member
0 Likes
951

Hi,

The Select query is fine, it is not mandatory to include all the key fields in the where clause, it all depends on the requirements.

Yes, putting all the key fields in the where clause will definitely help to fetch data faster. Since system has to less check for data, it can directly go keeping all the key fields as search criteria.

Thanks & Regards,

Navneeth K.

Read only

JozsefSzikszai
Active Contributor
0 Likes
950

looks like the SELECT is in a LOOP (because of the wa_...), which is not a good technique, however you have to run SE30 first to analyse where are the performance issues in the program.

Read only

Former Member
0 Likes
950

praveena you can yourself judge your program's performance,

SAP has provided SLIN check,code inspector etc..

one way i can tell you :open your program and in the menu :

Program -> Check -> Code Inspector

another way you can goto tcode SE30 for runtime analysis.

Also search for your querry on sdn forum, i think so many posts had already been on this topic.

Sid

Read only

Former Member
0 Likes
950

Hi,

Whenever you are using the select statements it is advisory to use the key fields otherwise some performance issues will come sometime run time errors can also occurs .

Thanks,

Thiru. R

Read only

Former Member
0 Likes
950

It is good to have key fields in the select queries where clause,but as we all know its not always possible due to various reasons, example we might want to find sales orders for a particular partner etc.

This is when indices come handy.

In your case, the query look good , but it seems that you are looping at some internal table into work area and then writing the select query. Avoid writing select queries in a loop, instead use FOR ALL ENTRIES or even better JOIN if you can join the tables.

example :


Select VDATU BDATU LIFNR NOTKZ from EORD into table IT_EORD
for all entries in it_final     " assuming your internal table is it_final and you are using an internal table
where MATNR = it_FINAL-MATNR
And WERKS = it_FINAL-WERKS.

You just need to be sure that in this case the table it_final is not initial.

regards,

Advait.

Read only

Former Member
0 Likes
950

Hi Praveena,

For better performance we try to use all the key fields in that table in where condition.

but it is not mandatory to use all.

regards

Kumar M.