Application Development 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: 

SELECT QUERY

Former Member
0 Kudos

This select query

sort itab by lifnr matnr ekorg werks esokz

SELECT lifnr matnr ekorg esokz werks datbi datab knumh

FROM a017

INTO CORRESPONDING FIELDS OF TABLE it_a017

FOR ALL ENTRIES IN itab

WHERE kschl = 'PB00' AND

lifnr = itab-lifnr AND

matnr = itab-matnr AND

ekorg = itab-ekorg AND

werks = itab-werks AND

esokz = itab-esokz AND

datbi GT sy-datum.

is taking a very very long time....the no. of records in itab are 70k and a017 has the equal number. I made sure itab is not empty before this statement is executed. Could someone help me with this...to improve performance....thanks.

7 REPLIES 7

Former Member
0 Kudos

one thing is if possible remove CORRESPONDING FIELDS OF

0 Kudos

KAPPL is the highest field in the composite, primary key. Add that field.

IF you do not have "know" the value(s) of KAPPL at execution time, then consider building a secondary index on KSCHL and some lower level fields.

Former Member
0 Kudos

You should add KAPPL to the WHERE clause. This will allow the SELECT statement to use the primary index.

Rob

Former Member
0 Kudos

Hi sandeep,

SELECT lifnr matnr ekorg esokz werks datbi datab knumh

FROM a017

INTO CORRESPONDING FIELDS OF TABLE it_a017

FOR ALL ENTRIES IN itab

WHERE <b>KAPPL = 'V'</b> and

kschl = 'PB00' AND

lifnr = itab-lifnr AND

matnr = itab-matnr AND

ekorg = itab-ekorg AND

werks = itab-werks AND

esokz = itab-esokz AND

datbi GT sy-datum and

<b>datab lt sy-datum</b>.

try this.

Rrds

KER

Former Member
0 Kudos

1. declared an internal table which will be having all the fields which you need.

by looking to your code i can say

data: begin of output occurs 0,

lifnr like a017-lifnr

matnr like a017-matnr,

ekorg like a017-ekorg,

esokz like a017-esokz,

werks like a017-werks,

datbi like a017-databi,

datab like a017-datab,

knumh like a017-knumh,

end of output.

sort itab by lifnr matnr ekorg werks esokz

*donot use corresponding fields.

select lifnr matnr ekorg esokz werks datbi datab knumh

FROM a017

INTO TABLE output

FOR ALL ENTRIES IN itab

WHERE kschl = 'PB00' AND

lifnr = itab-lifnr AND

matnr = itab-matnr AND

ekorg = itab-ekorg AND

werks = itab-werks AND

esokz = itab-esokz AND

datbi GT sy-datum.

Former Member
0 Kudos

The issue is resolved...thanks very much guys...i really appreciate it...

Former Member
0 Kudos

The issue is resolved...thanks very much guys...i really appreciate it...