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: 

how to tune expencesive sql statement

Former Member
0 Kudos

Hi,

I have an expencesive sql statement.

how to tune this one.

  • Get Q linked to position

lt_objid[] = I_OBJID_TAB[].

IF NOT LT_OBJID[] IS INITIAL.

SELECT OBJID SOBID INTO TABLE LT_STOQ

FROM HRP1001

FOR ALL ENTRIES IN LT_OBJID

WHERE OTYPE = 'S'

AND OBJID = LT_OBJID-OBJID

AND PLVAR = '01'

AND RSIGN = 'A'

AND RELAT = 'ZPC'

AND ISTAT = '1'

AND BEGDA <= KDATE

AND ENDDA >= KDATE

AND SCLAS = 'Q'.

IF SY-SUBRC = 0.

LOOP AT LT_STOQ.

LT_OBJID2-OBJID = LT_STOQ-SOBID.

APPEND LT_OBJID2.

ENDLOOP.

SORT LT_OBJID2.

DELETE ADJACENT DUPLICATES FROM lt_objid2.

ENDIF.

Thanks in Advance

1 REPLY 1

Former Member
0 Kudos

Since your using only OBJID field in for all entering deleting adajcent duplicate comparing only with oBJID should be done . Did you do that ??? If not do it it will have impact on your performance.

SORT LT_OBJID by OBJID.

DELETE ADJACENT DUPLICATES FROM lt_objid comparing OBJID.