<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Select statement Performence issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308245#M1636263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES : BEGIN OF T_EXIDV,
  LGNUM  type lqua-LGNUM,
LQNUM    type  lqua-lqnum ,
LENUM    type lqua-lenum ,
MATNR    type  lqua-matnr ,
*EXIDV TYPE EXIDV,
END OF T_EXIDV.


TYPES : BEGIN OF T_VEKP,
VENUM TYPE VENUM,
EXIDV TYPE EXIDV,
END OF T_VEKP.

DATA : IT_EXIDV TYPE TABLE OF T_EXIDV.
DATA : IT_VEKP TYPE TABLE OF T_VEKP.

*Get all HU's in LQUA table
SELECT lgnum lqnum LENUM matnr
  FROM LQUA
INTO CORRESPONDING FIELDS OF TABLE  IT_EXIDV.

if it_exidv[] is  not   INITIAL .

*Get all entries from VEKP table
SELECT VENUM EXIDV
  FROM VEKP
INTO CORRESPONDING FIELDS OF TABLE IT_VEKP
where venum = vekp~venum    .
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" You can use  in  above manner  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i did/nt understant where you find EXIDV  IN LQUA  table  ...&lt;/P&gt;&lt;P&gt;According to your  logic  =&amp;gt; there is no field exidv &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Get all HU's in LQUA table
SELECT LENUM FROM LQUA INTO TABLE IT_EXIDV.
IF SY-SUBRC = 0.
SORT IT_EXIDV BY EXIDV.
*Delete adjacent duplicates
DELETE ADJACENT DUPLICATES FROM IT_EXIDV.
DELETE TABLE IT_EXIDV WITH TABLE KEY EXIDV = ''.
*Get all entries from VEKP table
SELECT VENUM EXIDV FROM VEKP INTO TABLE IT_VEKP
FOR ALL ENTRIES IN IT_EXIDV
WHERE EXIDV = IT_EXIDV-EXIDV.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Dec 2011 04:32:44 GMT</pubDate>
    <dc:creator>deepak_dhamat</dc:creator>
    <dc:date>2011-12-04T04:32:44Z</dc:date>
    <item>
      <title>Select statement Performence issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308243#M1636261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I am having performence issues with below code and select statement, please help me. &lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF T_EXIDV,&lt;/P&gt;&lt;P&gt;          EXIDV   TYPE EXIDV,&lt;/P&gt;&lt;P&gt;        END OF T_EXIDV.&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF T_VEKP,&lt;/P&gt;&lt;P&gt;          VENUM  TYPE VENUM,&lt;/P&gt;&lt;P&gt;          EXIDV  TYPE EXIDV,&lt;/P&gt;&lt;P&gt;        END OF T_VEKP.&lt;/P&gt;&lt;P&gt;DATA : IT_EXIDV   TYPE TABLE OF T_EXIDV.&lt;/P&gt;&lt;P&gt;DATA : IT_VEKP    TYPE TABLE OF T_VEKP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Get all HU's in LQUA table&lt;/P&gt;&lt;P&gt;  SELECT LENUM FROM LQUA INTO TABLE IT_EXIDV.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    SORT IT_EXIDV BY EXIDV.&lt;/P&gt;&lt;P&gt;*Delete adjacent duplicates&lt;/P&gt;&lt;P&gt;    DELETE ADJACENT DUPLICATES FROM IT_EXIDV.&lt;/P&gt;&lt;P&gt;    DELETE TABLE IT_EXIDV WITH TABLE KEY EXIDV = ''.&lt;/P&gt;&lt;P&gt;*Get all entries from VEKP table&lt;/P&gt;&lt;P&gt;    &lt;STRONG&gt;SELECT VENUM EXIDV FROM VEKP INTO TABLE IT_VEKP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;      &lt;STRONG&gt;FOR ALL ENTRIES IN IT_EXIDV&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;      &lt;STRONG&gt;WHERE EXIDV = IT_EXIDV-EXIDV.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In above select statement (highlighted in bold) is taking very very long time to get input into table IT_VEKP. Well IT_EXIDV internal table has 200,000 records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;SB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 19:56:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308243#M1636261</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-03T19:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement Performence issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308244#M1636262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The statement does not look very good. FOR ALL ENTRIES IN is automatically packaging the SQL statement to restrict its size. On most systems the default package size is 5 so the FOR ALL ENTRIES IN statement is sending a DB request for every 5 table entries in IT_EXIDV resulting in 40.000 selects. This should explain the horrible performance. In addition the field you use is not the primary key. It might be that the DB fails to grab the existing secondary index on this field which is VEKP~C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So check the explain for this statement. It should show if the system is using the correct index. If not updating database statistics or hard definition of the index to use might bring some improvement. Furthermore tailoring the package size might bring some effect. Overall I fear that in the end the performance improvement might not be significant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So an alternative path to get the records with less select and perhaps transfer of processing from the database to the abap runtime might be needed. How many records does VEKP table has? How many record does the select get from the database? Can you get an set of database records which includes the records you actually need with other attributes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Roman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 22:43:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308244#M1636262</guid>
      <dc:creator>romanweise</dc:creator>
      <dc:date>2011-12-03T22:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement Performence issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308245#M1636263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES : BEGIN OF T_EXIDV,
  LGNUM  type lqua-LGNUM,
LQNUM    type  lqua-lqnum ,
LENUM    type lqua-lenum ,
MATNR    type  lqua-matnr ,
*EXIDV TYPE EXIDV,
END OF T_EXIDV.


TYPES : BEGIN OF T_VEKP,
VENUM TYPE VENUM,
EXIDV TYPE EXIDV,
END OF T_VEKP.

DATA : IT_EXIDV TYPE TABLE OF T_EXIDV.
DATA : IT_VEKP TYPE TABLE OF T_VEKP.

*Get all HU's in LQUA table
SELECT lgnum lqnum LENUM matnr
  FROM LQUA
INTO CORRESPONDING FIELDS OF TABLE  IT_EXIDV.

if it_exidv[] is  not   INITIAL .

*Get all entries from VEKP table
SELECT VENUM EXIDV
  FROM VEKP
INTO CORRESPONDING FIELDS OF TABLE IT_VEKP
where venum = vekp~venum    .
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" You can use  in  above manner  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i did/nt understant where you find EXIDV  IN LQUA  table  ...&lt;/P&gt;&lt;P&gt;According to your  logic  =&amp;gt; there is no field exidv &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Get all HU's in LQUA table
SELECT LENUM FROM LQUA INTO TABLE IT_EXIDV.
IF SY-SUBRC = 0.
SORT IT_EXIDV BY EXIDV.
*Delete adjacent duplicates
DELETE ADJACENT DUPLICATES FROM IT_EXIDV.
DELETE TABLE IT_EXIDV WITH TABLE KEY EXIDV = ''.
*Get all entries from VEKP table
SELECT VENUM EXIDV FROM VEKP INTO TABLE IT_VEKP
FOR ALL ENTRIES IN IT_EXIDV
WHERE EXIDV = IT_EXIDV-EXIDV.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Dec 2011 04:32:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308245#M1636263</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2011-12-04T04:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement Performence issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308246#M1636264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi i have resloved it by myself by creating binary search and secondary indexes on tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 19:27:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-performence-issue/m-p/8308246#M1636264</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-05T19:27:05Z</dc:date>
    </item>
  </channel>
</rss>

