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

Query optimizaing for performance tune

Former Member
0 Likes
804

Hi guys,

The below query is taking a lot of time to execute.The main problem is with table S022.This table is going for full table scan everytime even if we give a lot of selection criteria.So is there any alternate table for S022.In selection screen the mandatory fields are Location,plant and Phase.

SELECT a~aufnr "Order number

e~arbpl "Work center

e~plnum "Plaaned order

b~objnr "Object number

a~werks "plant

c~charg "Batch

d~gamng "qty

d~gmein "UOM

d~plnbez "Material

d~aufpl "routing no

d~aprio "Order priority

d~fevor "Responsible planner group/department

f~aufpl "Routing no

f~aplzl "general counter

f~vornr "Phase

f~arbid "workcenter

f~ltxa1 "text

g~objty "Object type

g~stand " Location

INTO CORRESPONDING FIELDS OF TABLE t_afpo

FROM ( ( ( ( ( s022 AS e

INNER JOIN aufk AS a ON aaufnr = eaufnr )

INNER JOIN jest AS b ON aobjnr = bobjnr )

INNER JOIN afpo AS c ON caufnr = aaufnr

AND awerks = cdwerk )

INNER JOIN afko AS d ON daufnr = caufnr

INNER JOIN afvc AS f ON faufpl = daufpl

AND fvornr = evornr )

INNER JOIN crhd AS g ON garbpl = earbpl

AND gobjid = farbid )

WHERE a~werks IN s_werks

AND d~plnbez IN s_matnr

AND d~fevor IN s_fevor

AND e~arbpl IN s_arbpl

AND e~aufnr IN s_aufnr

AND a~auart IN r_auart

AND e~ssavd IN s_date

AND e~vornr IN s_vornr

AND g~stand IN s_stand

AND a~loekz NE 'X'

AND b~stat = c_i0002

AND b~inact = space.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
765

Hi,

i would suggest that dont put too many joins in the select statement..

if possible try to put mulitple select statements using "for all entries".

and also join the table only with key fields so that the data fetching will be more faster..

if you are not able to use the key fields try with index fields provided by SAP..

if that is also not working then create Zindex field for the table which is using more time to fetch the data.

Regards

JK

Hi guys,

The below query is taking a lot of time to execute.The main problem is with table S022.This table is going for full table scan everytime even if we give a lot of selection criteria.So is there any alternate table for S022.In selection screen the mandatory fields are Location,plant and Phase.

SELECT a~aufnr "Order number

e~arbpl "Work center

e~plnum "Plaaned order

b~objnr "Object number

a~werks "plant

c~charg "Batch

d~gamng "qty

d~gmein "UOM

d~plnbez "Material

d~aufpl "routing no

d~aprio "Order priority

d~fevor "Responsible planner group/department

f~aufpl "Routing no

f~aplzl "general counter

f~vornr "Phase

f~arbid "workcenter

f~ltxa1 "text

g~objty "Object type

g~stand " Location

INTO CORRESPONDING FIELDS OF TABLE t_afpo

FROM ( ( ( ( ( s022 AS e

INNER JOIN aufk AS a ON aaufnr = eaufnr )

INNER JOIN jest AS b ON aobjnr = bobjnr )

INNER JOIN afpo AS c ON caufnr = aaufnr

AND awerks = cdwerk )

INNER JOIN afko AS d ON daufnr = caufnr

INNER JOIN afvc AS f ON faufpl = daufpl

AND fvornr = evornr )

INNER JOIN crhd AS g ON garbpl = earbpl

AND gobjid = farbid )

WHERE a~werks IN s_werks

AND d~plnbez IN s_matnr

AND d~fevor IN s_fevor

AND e~arbpl IN s_arbpl

AND e~aufnr IN s_aufnr

AND a~auart IN r_auart

AND e~ssavd IN s_date

AND e~vornr IN s_vornr

AND g~stand IN s_stand

AND a~loekz NE 'X'

AND b~stat = c_i0002

AND b~inact = space.

5 REPLIES 5
Read only

Former Member
0 Likes
766

Hi,

i would suggest that dont put too many joins in the select statement..

if possible try to put mulitple select statements using "for all entries".

and also join the table only with key fields so that the data fetching will be more faster..

if you are not able to use the key fields try with index fields provided by SAP..

if that is also not working then create Zindex field for the table which is using more time to fetch the data.

Regards

JK

Read only

0 Likes
765

Hi JK,

You mean to say Zindex for the SAP standard tables?..Please elaborate in detail.

Read only

0 Likes
765

Hi,

Sorry for the late response. i was on vacation.

yes.. we can create Zindex in the standard table which will act as an secondary index and will reterive the data faster.

Regards

JK

Read only

0 Likes
765

JK, could you please tell me the procedure for that..

Read only

0 Likes
765

Solved..