<?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: Native SQL Statement help! in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778847#M1464161</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys &lt;SPAN __jive_emoticon_name="grin"&gt;&lt;/SPAN&gt; I think it is solved.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Apr 2010 03:07:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-04-26T03:07:39Z</dc:date>
    <item>
      <title>Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778835#M1464149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need some help here. &lt;/P&gt;&lt;P&gt;I have a requirement to select from Microsoft SQL database&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I select with RANGE internal tables? As you can see, I have 4 range tables for this.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BElow are my codes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;EXEC SQL.
    CONNECT TO 'CONNECTION_NAME'
  ENDEXEC.

  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE 'Unable to connect to CONNECTION_NAME' TYPE 'E' DISPLAY LIKE 'I'.
    RETURN.
  ENDIF.

* Define database cursor
  EXEC SQL.
    OPEN dbcur FOR
            SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                   qty, zopcd, bstnk, wekunnr
              FROM &amp;lt;TABLE_NAME&amp;gt;
             WHERE month IN i_month
               AND yyear IN i_year
               AND kunnr IN i_kunnr
               AND bstnk IN i_bstnk
  ENDEXEC.

* Fill itab
  DO.

    EXEC SQL.
      FETCH NEXT dbcur INTO :l_dest-name1,
                            :l_dest-zvctk,
                            :l_dest-kunnr,
                            :l_dest-yyear,
                            :l_dest-mmonth,
                            :l_dest-matnr,
                            :l_dest-qty,
                            :l_dest-zopcd,
                            :l_dest-bstnk,
                            :l_dest-wekunnr
    ENDEXEC.

    IF sy-subrc &amp;lt;&amp;gt; 0.
      EXIT.
    ELSE.
      APPEND l_dest TO it_dest.
    ENDIF.
  ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its giving me a shortdump&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;     OPEN dbcur FOR&lt;/P&gt;&lt;P&gt;   35             SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,&lt;/P&gt;&lt;P&gt;   36                    qty, zopcd, bstnk, wekunnr&lt;/P&gt;&lt;P&gt;   37               FROM v_promise_sa&lt;/P&gt;&lt;P&gt;   38              WHERE month IN i_month[]&lt;/P&gt;&lt;P&gt;   39                AND yyear IN i_year[]&lt;/P&gt;&lt;P&gt;   40                AND kunnr IN i_kunnr[]&lt;/P&gt;&lt;P&gt;   41                AND bstnk IN i_bstnk[]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error message:&lt;/P&gt;&lt;P&gt;Database error text........: "[Microsoft][SQL Server Native Client 10.0][SQL&lt;/P&gt;&lt;P&gt; Server]Incorrect syntax near 'i_month'."&lt;/P&gt;&lt;P&gt;Database error code........: 102&lt;/P&gt;&lt;P&gt;Triggering SQL statement...: "SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,&lt;/P&gt;&lt;P&gt; qty, zopcd, bstnk, wekunnr FROM &amp;lt;TABLE_NAME&amp;gt; WHERE month IN i_month[] AND&lt;/P&gt;&lt;P&gt; yyear IN i_year[] AND kunnr IN i_kunnr[] AND bstnk IN i_bstnk[]"&lt;/P&gt;&lt;P&gt;Internal call code.........: "[DBDS/NEW DSQL]"&lt;/P&gt;&lt;P&gt;Please check the entries in the system log (Transaction SM21).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone guide me? If I do not enter the where clause, it is selecting fine.&lt;/P&gt;&lt;P&gt;Appreciate it guys! Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 08:50:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778835#M1464149</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-21T08:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778836#M1464150</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 are not able to understand the problem which you are facing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Be clear in short.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anil.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 09:02:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778836#M1464150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-21T09:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778837#M1464151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is, I dont know how the syntax should be when it comes to do native select statements with WHERE clause using RANGE internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its giving me short dump &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Database error text........: "Microsofthttp://SQL Server Native Client 10.0[SQL
Server]Incorrect syntax near 'i_month'."
Database error code........: 102
Triggering SQL statement...: "SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
qty, zopcd, bstnk, wekunnr FROM &amp;lt;TABLE_NAME&amp;gt; WHERE month IN i_month[] AND
yyear IN i_year] AND kunnr IN i_kunnr[ AND bstnk IN i_bstnk[]"
Internal call code.........: "DBDS/NEW DSQL"
Please check the entries in the system log (Transaction SM21).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is, what am I doing wrong? Can someone guide me on the correct syntax for native select statement with RANGE values?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 09:10:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778837#M1464151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-21T09:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778838#M1464152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check This ,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
EXEC SQL.
    OPEN dbcur FOR
            SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                   qty, zopcd, bstnk, wekunnr
              FROM &amp;lt;TABLE_NAME&amp;gt;
             WHERE month IN i_month "check this I think field is MMONTH
               AND yyear IN i_year
               AND kunnr IN i_kunnr
               AND bstnk IN i_bstnk
  ENDEXEC.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raghava Channoru&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 09:16:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778838#M1464152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-21T09:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778839#M1464153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think IN is allowed in Native SQL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;"Native SQL statements do not fall within the scope of ABAP and do not follow ABAP syntax"&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source: [http://help.sap.com/abapdocu_70/en/ABENNATIVESQL.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An easy workaround will be select the data from the SQL server w/o the range table into the internal table &amp;amp; then delete the entries from the internal table which do not fall in the range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DELETE it_dest
WHERE month NOT IN i_month
AND yyear NOT IN i_year
AND kunnr NOT IN i_kunnr
AND bstnk NOT IN i_bstnk&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just out of curiosity i checked what could be the native sql operator similar to IN. I got these links, may be they interest you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[http://www.sql-tutorial.net/SQL-IN.asp]&lt;/P&gt;&lt;P&gt;[http://www.sql-tutorial.net/SQL-BETWEEN.asp]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on Apr 21, 2010 2:55 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 09:19:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778839#M1464153</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-04-21T09:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778840#M1464154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yea, I realized that earlier. Anyway its not that which is causing the error. Some progress now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;EXEC SQL.
    OPEN dbcur FOR
            SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                   qty, zopcd, bstnk, wekunnr
              FROM v_promise_sa
             WHERE mmonth = :i_month
               AND yyear  = :i_year
               AND ( kunnr BETWEEN :i_kunnr-low AND :i_kunnr-high )
               AND ( bstnk BETWEEN :i_bstnk-low AND :i_bstnk-high )
  ENDEXEC.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No shortdump but the BETWEEN syntax is making it not select data. need to figure it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 09:33:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778840#M1464154</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-21T09:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778841#M1464155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The fields :i_kunnr-low , :i_kunnr-high,etc. don't contain any data unless you are inside a LOOP. So basically you need something like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT i_kunnr.
 LOOP at i_bstnk.
  EXEC SQL.
             SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                   qty, zopcd, bstnk, wekunnr
              FROM v_promise_sa
             WHERE mmonth = :i_month
               AND yyear  = :i_year
               AND ( kunnr BETWEEN :i_kunnr-low AND :i_kunnr-high )
              AND ( bstnk BETWEEN :i_bstnk-low AND :i_bstnk-high )               
   ENDEXEC.
  ENDLOOP.
 ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW: Does the table v_promise_sa exist in the SAP DDIC?  If yes I would recommend to use Open-SQL with range tables instead of Native-SQL with nested LOOPs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 15:54:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778841#M1464155</guid>
      <dc:creator>adrian_dorn</dc:creator>
      <dc:date>2010-04-21T15:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778842#M1464156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, none of this will work if the range tables has anything but EQ, I and ranges of values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It won't work with individual values, excluding or patterns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Apr 2010 16:24:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778842#M1464156</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-22T16:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778843#M1464157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Well, none of this will work if the range tables has anything but EQ, I and ranges of values.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; It won't work with individual values, excluding or patterns.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;True. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the code sample in SlowABAPer's last posting I assumed that the range tables have only BT records. If this assumption is not correct and the range tables have a mixture of EQ, CP, BT, etc, the situation gets more complicated. In this case I can only think of the following solution: Create an extra internal table ITAB with 4 fields &lt;/P&gt;&lt;P&gt;                        month&lt;/P&gt;&lt;P&gt;                        year&lt;/P&gt;&lt;P&gt;                        kunnr&lt;/P&gt;&lt;P&gt;                        bstnk&lt;/P&gt;&lt;P&gt;and fill this table with all possible records resulting from the values of the range tables. Afterwards loop over the resulting ITAB and inside the loop do a EXEC SQL with a WHERE which has just EQ operators. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Remark @ Slow ABAPer : Not really a nice coding, but you won't find a better way of doing it with NATIVE-SQL. Therefore as I mentioned in my previous posting: If the table exists in the SAP DDIC, you should use Open-SQL instead of Native-SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Apr 2010 16:57:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778843#M1464157</guid>
      <dc:creator>adrian_dorn</dc:creator>
      <dc:date>2010-04-22T16:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778844#M1464158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; By the code sample in SlowABAPer's last posting I assumed that the range tables have only BT records.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;By the name Slow ABAPER has chosen, I wouldn't assume anything &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The suggestion to use open SQL if possible would be ideal though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Apr 2010 17:23:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778844#M1464158</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-22T17:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778845#M1464159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lol, Come guys, don't judge me by just my forum nick man. It was just something random during registration a few years back...was indeed new in ABAP language &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But anyway, the table v_promimse_sa is not in the DDIC, its some microsoft MYSQL database or something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anyway what I did now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;EXEC SQL.
    CONNECT TO 'MSSQL_PROMISE'
  ENDEXEC.

  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE 'Unable to connect to MSSQL_PROMISE' TYPE 'E' DISPLAY LIKE 'I'.
    RETURN.
  ENDIF.

* Define database cursor
  EXEC SQL.
    OPEN dbcur FOR
            SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                   qty, zopcd, bstnk, wekunnr
              FROM v_promise_sa
             WHERE mmonth = :i_month
               AND yyear  = :i_year
*               AND ( kunnr BETWEEN :i_kunnr-low AND :i_kunnr-high )
*               AND ( bstnk BETWEEN :i_bstnk-low AND :i_bstnk-high )
  ENDEXEC.

* Fill itab
  DO.

    EXEC SQL.
      FETCH NEXT dbcur INTO :l_dest-name1,
                            :l_dest-zvctk,
                            :l_dest-kunnr,
                            :l_dest-yyear,
                            :l_dest-mmonth,
                            :l_dest-matnr,
                            :l_dest-qty,
                            :l_dest-zopcd,
                            :l_dest-bstnk,
                            :l_dest-wekunnr
    ENDEXEC.

    IF sy-subrc &amp;lt;&amp;gt; 0.
      EXIT.
    ELSE.
      APPEND l_dest TO it_dest.
    ENDIF.
  ENDDO.

*    EXEC SQL.
*      CLOSE dbcur
*    ENDEXEC.

  DELETE it_dest WHERE kunnr NOT IN i_kunnr
                   AND bstnk NOT IN i_bstnk.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, after checking with the functional person, there are only 3 records so I guess the selection + filtering is working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="grin"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Apr 2010 01:14:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778845#M1464159</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-26T01:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778846#M1464160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, if your question is answered, please mark it as such.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Apr 2010 02:25:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778846#M1464160</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-26T02:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Statement help!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778847#M1464161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys &lt;SPAN __jive_emoticon_name="grin"&gt;&lt;/SPAN&gt; I think it is solved.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Apr 2010 03:07:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-statement-help/m-p/6778847#M1464161</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-26T03:07:39Z</dc:date>
    </item>
  </channel>
</rss>

