<?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 select query + ABAP logic in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-abap-logic/m-p/5419349#M1244021</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAPians,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to find best way of fetching some perculiar entries from a DB table. The scenario is explianed below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If the values/entries in column C1 equal to value 'b' for a given key number in column T1, then it should be selected. (Duplicate keys are possible. )&lt;/P&gt;&lt;P&gt;2. If there is anyother entry/value in column C1 along with value 'b' for a given key number (T1) it should be discarded. &lt;/P&gt;&lt;P&gt;3. There are millions of entries in DB table, hence we want to cursor logic which fetches only 1000 at a time. &lt;/P&gt;&lt;P&gt;4. For a given Key number (in T1) there could be entries more than 1000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(example: &lt;/P&gt;&lt;P&gt;Consider the following TABLE entries With T1 and C1 as two coloumns/fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T1                                        C1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;                                    -&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;9866     b&lt;/P&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9877                                     a&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     c&lt;/P&gt;&lt;P&gt;9899                                     a&lt;/P&gt;&lt;P&gt;9899                                     b&lt;/P&gt;&lt;P&gt;9900                                     b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is to retrieve the numbers whose C1 values are only b.In the above example 9877 and 9899&lt;/P&gt;&lt;P&gt;should not be retrieved as they have a C1 value other than b.[this step is done]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The database may contain million records.Due to performance reasons we cannot take more than 1000 entries at a time from the database.Now consider the following case&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case:&lt;/P&gt;&lt;P&gt;T1                                        C1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;                                    -&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9877                                     a------3&lt;/P&gt;&lt;P&gt;9877                                     c&lt;/P&gt;&lt;P&gt;9877                                     b-------5&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;9877                                    b------1000&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;9877                                    b-------1500  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above case consider the number 9877 for which more than 1000 entries exits and from 5 th entry to 1500 entry the c1 value is 'b', in this case for the first 1000 entries 9877 will not satisfy the given condition hence will be retrieved, but during the second run 9877 is retrieved which is incorrect.There may be thousands of entries for a single T1 number and  more possible C1 values and th table is not sorted.&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Mar 2009 19:38:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-21T19:38:02Z</dc:date>
    <item>
      <title>select query + ABAP logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-abap-logic/m-p/5419349#M1244021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAPians,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to find best way of fetching some perculiar entries from a DB table. The scenario is explianed below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If the values/entries in column C1 equal to value 'b' for a given key number in column T1, then it should be selected. (Duplicate keys are possible. )&lt;/P&gt;&lt;P&gt;2. If there is anyother entry/value in column C1 along with value 'b' for a given key number (T1) it should be discarded. &lt;/P&gt;&lt;P&gt;3. There are millions of entries in DB table, hence we want to cursor logic which fetches only 1000 at a time. &lt;/P&gt;&lt;P&gt;4. For a given Key number (in T1) there could be entries more than 1000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(example: &lt;/P&gt;&lt;P&gt;Consider the following TABLE entries With T1 and C1 as two coloumns/fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T1                                        C1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;                                    -&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;9866     b&lt;/P&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9877                                     a&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     c&lt;/P&gt;&lt;P&gt;9899                                     a&lt;/P&gt;&lt;P&gt;9899                                     b&lt;/P&gt;&lt;P&gt;9900                                     b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is to retrieve the numbers whose C1 values are only b.In the above example 9877 and 9899&lt;/P&gt;&lt;P&gt;should not be retrieved as they have a C1 value other than b.[this step is done]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The database may contain million records.Due to performance reasons we cannot take more than 1000 entries at a time from the database.Now consider the following case&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case:&lt;/P&gt;&lt;P&gt;T1                                        C1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;                                    -&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9866                                     b&lt;/P&gt;&lt;P&gt;9877                                     a------3&lt;/P&gt;&lt;P&gt;9877                                     c&lt;/P&gt;&lt;P&gt;9877                                     b-------5&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;9877                                     b&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;9877                                    b------1000&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;9877                                    b-------1500  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above case consider the number 9877 for which more than 1000 entries exits and from 5 th entry to 1500 entry the c1 value is 'b', in this case for the first 1000 entries 9877 will not satisfy the given condition hence will be retrieved, but during the second run 9877 is retrieved which is incorrect.There may be thousands of entries for a single T1 number and  more possible C1 values and th table is not sorted.&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Mar 2009 19:38:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-abap-logic/m-p/5419349#M1244021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-21T19:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: select query + ABAP logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-abap-logic/m-p/5419350#M1244022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry to give you the reply so late, never the less what you want is to use the the &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: packsize      TYPE i VALUE 1000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT (tab_fields) FROM glpca&lt;/P&gt;&lt;P&gt;         &lt;STRONG&gt;PACKAGE SIZE packsize&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;         APPENDING CORRESPONDING FIELDS OF TABLE i_glpca_i&lt;/P&gt;&lt;P&gt;         WHERE rldnr     IN rldnr&lt;/P&gt;&lt;P&gt;           AND rrcty     IN rrcty&lt;/P&gt;&lt;P&gt;           AND rvers     IN rvers&lt;/P&gt;&lt;P&gt;           AND kokrs     IN kokrs&lt;/P&gt;&lt;P&gt;           AND rbukrs    IN rbukrs&lt;/P&gt;&lt;P&gt;           AND ryear     IN ryear&lt;/P&gt;&lt;P&gt;           AND racct     IN racct&lt;/P&gt;&lt;P&gt;           AND rprctr    IN prctr&lt;/P&gt;&lt;P&gt;           AND sprctr    IN pprctr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you might notice the logig to pick up records 1000 at a time the PACKAGE SIZE addition is used. Because this kind of selection loops it allows for you to get records in chunks of 1000 if there are less than 1000 they are also taken up, this allows for you to manage the allocation memory and exit the selection once you have taken your desired number of records!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tatenda Chaibva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Mar 2010 07:53:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-abap-logic/m-p/5419350#M1244022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-10T07:53:37Z</dc:date>
    </item>
  </channel>
</rss>

