<?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: Query Optimisation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668884#M883712</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mick,&lt;/P&gt;&lt;P&gt;Try using Package size in u r query.Package size would get data into u r internal table in chunks of 2GB.&lt;/P&gt;&lt;P&gt;C below...i have picked it up from one of WIKI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some times tables can have very large amount of data which may exceed 2GB limit of the internal table and may lead to short dump. In that case we can use the below technique to fetch the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It has 3 steps :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Calculting the memory occupied by one record.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. Calculating maximum no of records that can be accomodated in the internal table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. Fetching that many records at a time and performing desired operation.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;parameters : P_table type DDOBJNAME.&lt;/P&gt;&lt;P&gt;DATA : db_cursor TYPE cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : lt_dfies       TYPE TABLE OF dfies,&lt;/P&gt;&lt;P&gt;       ls_dfies       TYPE          dfies,&lt;/P&gt;&lt;P&gt;       struc_size     TYPE i VALUE 0,&lt;/P&gt;&lt;P&gt;       g_package_size TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;xtab&amp;gt; TYPE any table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : l_refitab type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data l_refitab type table of (p_table).&lt;/P&gt;&lt;P&gt;assign l_refitab-&amp;gt;* to &amp;lt;xtab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get nametab&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'DDIF_NAMETAB_GET'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;  tabname = p_table&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;  dfies_tab = lt_dfies&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;  not_found = 1&lt;/P&gt;&lt;P&gt;  OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Logic for calculating Package size&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To calculate the memory taken by one record&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT lt_dfies INTO ls_dfies.&lt;/P&gt;&lt;P&gt;    struc_size = struc_size + ls_dfies-leng.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="5" type="ul"&gt;&lt;P&gt;To calculaten maximum no of records that can be accomodated in 2gb&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt; g_package_size = 2147483648 / struc_size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; OPEN CURSOR WITH HOLD db_cursor FOR&lt;/P&gt;&lt;P&gt; SELECT * FROM (P_table)&lt;/P&gt;&lt;P&gt; BYPASSING BUFFER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;To Fetch data in chunks of 2gb &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt; FETCH NEXT CURSOR db_cursor&lt;/P&gt;&lt;P&gt; INTO CORRESPONDING FIELDS OF TABLE &amp;lt;xtab&amp;gt;&lt;/P&gt;&lt;P&gt; PACKAGE SIZE g_package_size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;    CLOSE CURSOR db_cursor.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt; ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Here do the operation you want on internal table &amp;lt;xtab_buf&amp;gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way ensures that you get data in chunks of 2GB and thus avoids short dump. As we are dynamically calculating the maximum no of records for 2GB, we are reducing the database hits to the minimum. It works for small tables as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Apr 2008 17:55:12 GMT</pubDate>
    <dc:creator>rahul2000</dc:creator>
    <dc:date>2008-04-15T17:55:12Z</dc:date>
    <item>
      <title>Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668878#M883706</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;P&gt;We have the following query which is causing performance issues. Let me know how can we optimise it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;       VBELN&lt;/P&gt;&lt;P&gt;       POSNR&lt;/P&gt;&lt;P&gt;       MATNR&lt;/P&gt;&lt;P&gt;       MEINS&lt;/P&gt;&lt;P&gt;       VRKME&lt;/P&gt;&lt;P&gt;       VSTEL&lt;/P&gt;&lt;P&gt;       ABGRU&lt;/P&gt;&lt;P&gt;       MVGR5&lt;/P&gt;&lt;P&gt;       CUOBJ&lt;/P&gt;&lt;P&gt;       NETPR&lt;/P&gt;&lt;P&gt;       ZMENG&lt;/P&gt;&lt;P&gt;       KWMENG&lt;/P&gt;&lt;P&gt;       KPEIN&lt;/P&gt;&lt;P&gt;       KMEIN&lt;/P&gt;&lt;P&gt;       NETWR&lt;/P&gt;&lt;P&gt;       WAERK&lt;/P&gt;&lt;P&gt;       Z_SERV_TYP_ORIG&lt;/P&gt;&lt;P&gt;       Z_SERV_TYP_DEST&lt;/P&gt;&lt;P&gt;       Z_SHIP_TYP_ORIG&lt;/P&gt;&lt;P&gt;       Z_SHIP_TYP_DEST&lt;/P&gt;&lt;P&gt;       Z_EQUIPMENT_TYPE&lt;/P&gt;&lt;P&gt;       Z_CONTAINER_SIZE&lt;/P&gt;&lt;P&gt;       Z_CONTAINER_TYPE&lt;/P&gt;&lt;P&gt;       Z_OTI&lt;/P&gt;&lt;P&gt;       Z_HUB_PORT&lt;/P&gt;&lt;P&gt;       Z_PASSTHROUGH&lt;/P&gt;&lt;P&gt;       Z_SHIPMENTTERM&lt;/P&gt;&lt;P&gt;       ARKTX&lt;/P&gt;&lt;P&gt;       KBMENG&lt;/P&gt;&lt;P&gt;     INTO TABLE I_VBAP&lt;/P&gt;&lt;P&gt;     FROM VBAP&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN I_VBAK&lt;/P&gt;&lt;P&gt;     WHERE VBELN            = I_VBAK-VBELN&lt;/P&gt;&lt;P&gt;     AND   MATNR            IN S_MATNR&lt;/P&gt;&lt;P&gt;     AND   Z_SERV_TYP_ORIG  IN S_SERTO&lt;/P&gt;&lt;P&gt;     AND   Z_SERV_TYP_DEST  IN S_SERTD&lt;/P&gt;&lt;P&gt;     AND   Z_SHIP_TYP_ORIG  IN S_STO&lt;/P&gt;&lt;P&gt;     AND   Z_SHIP_TYP_DEST  IN S_STD&lt;/P&gt;&lt;P&gt;     AND   Z_EQUIPMENT_TYPE IN S_EQTY&lt;/P&gt;&lt;P&gt;     AND   Z_CONTAINER_SIZE IN S_CONTS&lt;/P&gt;&lt;P&gt;     AND   Z_CONTAINER_TYPE IN S_CONTT&lt;/P&gt;&lt;P&gt;     AND   Z_VESSEL_CODE    IN S_VES&lt;/P&gt;&lt;P&gt;     AND   Z_VOYAGE_NUMBER  IN S_VOY&lt;/P&gt;&lt;P&gt;     AND   Z_OTI            IN S_OTI&lt;/P&gt;&lt;P&gt;     AND   Z_HUB_PORT       IN S_HUB&lt;/P&gt;&lt;P&gt;     AND   Z_PASSTHROUGH    IN S_PASS&lt;/P&gt;&lt;P&gt;     AND   Z_SHIPMENTTERM   IN S_ST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only field compulsory in the where clause is the sales order number (VBELN). Rest all fields are optional and may or may not have values in them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 12:09:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668878#M883706</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T12:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668879#M883707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would start by sorting the i_vbak table by VBELN, and deleting any duplicates from this table ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 12:16:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668879#M883707</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T12:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668880#M883708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;well, if I_VBAK is empty or has many (all?) existing entries of VBAK, then you're scanning the entire VBAP table, which will take time no matter what, depending on the number of entries.&lt;/P&gt;&lt;P&gt;At least make sure I_VBAK is not empty and you have it sorted by VBELN. If S_MATNR contains only few material numbers, access via VAPMA should be investigated.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 12:19:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668880#M883708</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-04-15T12:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668881#M883709</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;P&gt;follow the instructions..&lt;/P&gt;&lt;P&gt;1. use the primary and secondary keys in the where condition .&lt;/P&gt;&lt;P&gt;2. use the sort statement &lt;/P&gt;&lt;P&gt;3. use the delete adjacent duplicates if necessary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please check the optimisation in the st05..and proceed..&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 12:20:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668881#M883709</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T12:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668882#M883710</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;P&gt;1) The internal table is already sorted. &lt;/P&gt;&lt;P&gt;2) The where clause contains the sales order no (VBELN)which is part of the primary key. We cannot have the item no (POSNR) in the where clause as we are querying VBAK first and then passing all the sales order nos to VBAP.&lt;/P&gt;&lt;P&gt;3) I_VBAK is not empty&lt;/P&gt;&lt;P&gt;I_VBAK can have a large no of entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 12:48:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668882#M883710</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T12:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668883#M883711</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;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 14:21:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668883#M883711</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T14:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668884#M883712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mick,&lt;/P&gt;&lt;P&gt;Try using Package size in u r query.Package size would get data into u r internal table in chunks of 2GB.&lt;/P&gt;&lt;P&gt;C below...i have picked it up from one of WIKI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some times tables can have very large amount of data which may exceed 2GB limit of the internal table and may lead to short dump. In that case we can use the below technique to fetch the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It has 3 steps :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Calculting the memory occupied by one record.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. Calculating maximum no of records that can be accomodated in the internal table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. Fetching that many records at a time and performing desired operation.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;parameters : P_table type DDOBJNAME.&lt;/P&gt;&lt;P&gt;DATA : db_cursor TYPE cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : lt_dfies       TYPE TABLE OF dfies,&lt;/P&gt;&lt;P&gt;       ls_dfies       TYPE          dfies,&lt;/P&gt;&lt;P&gt;       struc_size     TYPE i VALUE 0,&lt;/P&gt;&lt;P&gt;       g_package_size TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;xtab&amp;gt; TYPE any table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : l_refitab type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data l_refitab type table of (p_table).&lt;/P&gt;&lt;P&gt;assign l_refitab-&amp;gt;* to &amp;lt;xtab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get nametab&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'DDIF_NAMETAB_GET'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;  tabname = p_table&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;  dfies_tab = lt_dfies&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;  not_found = 1&lt;/P&gt;&lt;P&gt;  OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Logic for calculating Package size&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To calculate the memory taken by one record&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT lt_dfies INTO ls_dfies.&lt;/P&gt;&lt;P&gt;    struc_size = struc_size + ls_dfies-leng.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="5" type="ul"&gt;&lt;P&gt;To calculaten maximum no of records that can be accomodated in 2gb&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt; g_package_size = 2147483648 / struc_size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; OPEN CURSOR WITH HOLD db_cursor FOR&lt;/P&gt;&lt;P&gt; SELECT * FROM (P_table)&lt;/P&gt;&lt;P&gt; BYPASSING BUFFER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;To Fetch data in chunks of 2gb &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt; FETCH NEXT CURSOR db_cursor&lt;/P&gt;&lt;P&gt; INTO CORRESPONDING FIELDS OF TABLE &amp;lt;xtab&amp;gt;&lt;/P&gt;&lt;P&gt; PACKAGE SIZE g_package_size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;    CLOSE CURSOR db_cursor.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt; ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Here do the operation you want on internal table &amp;lt;xtab_buf&amp;gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way ensures that you get data in chunks of 2GB and thus avoids short dump. As we are dynamically calculating the maximum no of records for 2GB, we are reducing the database hits to the minimum. It works for small tables as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 17:55:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668884#M883712</guid>
      <dc:creator>rahul2000</dc:creator>
      <dc:date>2008-04-15T17:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query Optimisation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668885#M883713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also Mick ,&lt;/P&gt;&lt;P&gt;I can c a lot of s_something in u r code.&lt;/P&gt;&lt;P&gt;i assume it is select option.&lt;/P&gt;&lt;P&gt;r u giving these selection criteria on u r selection screen before executing the report?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Giving all of this would really help as it would fasten u r report&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 17:57:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-optimisation/m-p/3668885#M883713</guid>
      <dc:creator>rahul2000</dc:creator>
      <dc:date>2008-04-15T17:57:53Z</dc:date>
    </item>
  </channel>
</rss>

