<?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: runtime error in  SQL statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954697#M66031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The easiest thing to do in all such cases is to get the records without that range and then delete them as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from cosp 
         into corresponding fields of table gt_cosp 
        where lednr = lv_lednr 
          and versn = p_vercost 
          and wrttp = lv_wrttp 
          and gjahr in r_gjahr.
if not gt_cosp[] is initial.
  delete gt_cosp where not ( kstar in r_kstar and
                             objnr in r_objnrs ).
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you think your 'r_gjahr' will also contain lot of records, then you should move that also into the delete statement and take it out of the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please don't forget to reward the helpful answers and close the post once resolved.&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;Srinivas&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Sep 2005 12:50:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-09-22T12:50:18Z</dc:date>
    <item>
      <title>runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954686#M66020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;I have a runtime during selection from database table due to large ranges in where condition. for example:&lt;/P&gt;&lt;P&gt;select * from cosp into corresponding &lt;/P&gt;&lt;P&gt;  fields of table gt_cosp  &lt;/P&gt;&lt;P&gt;  where objnr in r_objnrs                &lt;/P&gt;&lt;P&gt;  and lednr = lv_lednr                 &lt;/P&gt;&lt;P&gt;  and versn = p_vercost                &lt;/P&gt;&lt;P&gt;  and wrttp = lv_wrttp                 &lt;/P&gt;&lt;P&gt;  and gjahr in r_gjahr                 &lt;/P&gt;&lt;P&gt;  and kstar in r_kstar. &lt;/P&gt;&lt;P&gt;The suggested solution is to use internal table instead of a range and use "for all entries" or to divide the ranges to smaller units.&lt;/P&gt;&lt;P&gt;As you see I have few ranges and this solution could be not effective in this case.&lt;/P&gt;&lt;P&gt;Do you have a better idea?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Far&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 07:37:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954686#M66020</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T07:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954687#M66021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welcome to SDN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i don't think ranges can give any runtime error here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 07:47:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954687#M66021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T07:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954688#M66022</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;can you post the error message and how manay entries you expect from the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 07:54:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954688#M66022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T07:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954689#M66023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes ranges have a limitation if number of entries are high. This depends on some database parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not sure of how many entries will be going in the ranges table at runtime, it is prferable to use "for all entries" , the compiler automatically fragments the select statements depending on database settings and you need not check this in ABAP code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In our system select fails if ranges have more than 3000 entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 07:55:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954689#M66023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T07:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954690#M66024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sanjay thanks for info&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think we can set this number(3000) for no. of entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what do you say&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 08:01:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954690#M66024</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T08:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954691#M66025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fariba&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can tried to limit the number of records are loaded in table range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I don't know how you fill those range, but you do it in more steps than one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt; R_RANGE(3) = 'IEQ'.&lt;/P&gt;&lt;P&gt; R_RANGE_LOW = ITAB-FIELD.&lt;/P&gt;&lt;P&gt; APPEND R_RANGE.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM &amp;lt;TABLE&amp;gt; INTO TABLE MY_TABLE&lt;/P&gt;&lt;P&gt;                            WHERE FIELD IN R_RANGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE ITAB LINES MAX_LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INDEX_FROM = 1.&lt;/P&gt;&lt;P&gt;INDEX_TO    = 100. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB FROM INDEX_FROM&lt;/P&gt;&lt;P&gt;             TO   INDEX_TO.&lt;/P&gt;&lt;P&gt; R_RANGE(3) = 'IEQ'.&lt;/P&gt;&lt;P&gt; R_RANGE_LOW = ITAB-FIELD.&lt;/P&gt;&lt;P&gt; APPEND R_RANGE.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM &amp;lt;TABLE&amp;gt; APPENDING INTO TABLE MY_TABLE&lt;/P&gt;&lt;P&gt;                            WHERE FIELD IN R_RANGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INDEX_FROM = INDEX_TO + 1.&lt;/P&gt;&lt;P&gt;IF INDEX_FROM &amp;gt; MAX_LINE.&lt;/P&gt;&lt;P&gt;  EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;INDEX_TO   = INDEX_TO + 100.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this way you select for all 100 hit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solve your problem depend on how you have to fill the range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 08:04:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954691#M66025</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T08:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954692#M66026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Surpreet ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not really the way you see . In database you have a limit on the length of SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAY&lt;/P&gt;&lt;P&gt;Select * from MARA where MATNR in S_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The databse interpretor will split the above into&lt;/P&gt;&lt;P&gt;Select Field1 Field2 .... from mara&lt;/P&gt;&lt;P&gt;  where matnr eq M1&lt;/P&gt;&lt;P&gt;    or matnr eq M2&lt;/P&gt;&lt;P&gt;     ......&lt;/P&gt;&lt;P&gt;     ......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have large number of entries the select statement may reach the thresold value and will fail. Thresold value is a database parameter .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When runtime error occurs you can see this in SM21 system log and see which parameter caused runtime error .&lt;/P&gt;&lt;P&gt;( Other parameter may cause eroor as well ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ST05 you can see how select statements are passed to database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"For all entries" takes care of above problem .&lt;/P&gt;&lt;P&gt;It splits the select statement depending on DB parameters dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 08:25:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954692#M66026</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T08:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954693#M66027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sanjay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks a lot for this info&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;i did not know this initially&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 08:28:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954693#M66027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T08:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954694#M66028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all of you,&lt;/P&gt;&lt;P&gt;but unfortunately all these answers don't help in my case.&lt;/P&gt;&lt;P&gt;You see, "for all entries" could be helpful if each line in the range contain only one value...&lt;/P&gt;&lt;P&gt;in my case the "low" and "high" are different, and that's the reason I use range value.&lt;/P&gt;&lt;P&gt;(this range is reached by using a function witch split a group to values)&lt;/P&gt;&lt;P&gt;The above solution is too clumsy and complicated, and I was expected SAP has more intelligent solution.&lt;/P&gt;&lt;P&gt;Thanks in any case.&lt;/P&gt;&lt;P&gt;Fariba&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 08:59:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954694#M66028</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T08:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954695#M66029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please once can you post you whole code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 09:02:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954695#M66029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T09:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954696#M66030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;  I have had the same problem (with Oracle DB) and, looking for some SAP notes, I found the solution that max bianchi has suggested.&lt;/P&gt;&lt;P&gt;I think it's the only solution.&lt;/P&gt;&lt;P&gt;Regards, Manuel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 09:12:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954696#M66030</guid>
      <dc:creator>manuel_bassani</dc:creator>
      <dc:date>2005-09-22T09:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error in  SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954697#M66031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The easiest thing to do in all such cases is to get the records without that range and then delete them as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from cosp 
         into corresponding fields of table gt_cosp 
        where lednr = lv_lednr 
          and versn = p_vercost 
          and wrttp = lv_wrttp 
          and gjahr in r_gjahr.
if not gt_cosp[] is initial.
  delete gt_cosp where not ( kstar in r_kstar and
                             objnr in r_objnrs ).
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you think your 'r_gjahr' will also contain lot of records, then you should move that also into the delete statement and take it out of the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please don't forget to reward the helpful answers and close the post once resolved.&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;Srinivas&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2005 12:50:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-in-sql-statement/m-p/954697#M66031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-22T12:50:18Z</dc:date>
    </item>
  </channel>
</rss>

