<?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 Open Sql Between in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359155#M1541712</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am Having Ztable like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MatgrpFrom	MatGrpTo	Department
1100  		1199		Process - Common
2000		2099		Mechanical-Old
2200		2299		Mechanical-New
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to fetch a department field by passing matgrp Eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATGRP = 2088 Means -&amp;gt; Mechanical-Old &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATGRP = 1150 Means -&amp;gt; Process - Common   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from Test 
where 
2088  between  MKTL_F  and  MKTL_T 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  Loop AT it_mara into wa_mara.      
    select Dept from ZMMT_MTGRP INTO lv_dept
      where 
      wa_mara-matkl  between  MKTL_F and MKTL_T .
      it_resb-matkl = wa_mara-matkl.
      it_resb-dept = lv_dept.
      MODIFY it_resb TRANSPORTING matkl dept where matnr = wa_mara-matnr.
    ENDSELECT.  
  ENDLOOP. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is throwing &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
wa_mara-matkl is unknown
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to implement in open SQL plz throw me light.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or please let me know best way to get this record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Oct 2010 07:49:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-10-20T07:49:51Z</dc:date>
    <item>
      <title>Open Sql Between</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359155#M1541712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am Having Ztable like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MatgrpFrom	MatGrpTo	Department
1100  		1199		Process - Common
2000		2099		Mechanical-Old
2200		2299		Mechanical-New
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to fetch a department field by passing matgrp Eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATGRP = 2088 Means -&amp;gt; Mechanical-Old &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATGRP = 1150 Means -&amp;gt; Process - Common   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * from Test 
where 
2088  between  MKTL_F  and  MKTL_T 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  Loop AT it_mara into wa_mara.      
    select Dept from ZMMT_MTGRP INTO lv_dept
      where 
      wa_mara-matkl  between  MKTL_F and MKTL_T .
      it_resb-matkl = wa_mara-matkl.
      it_resb-dept = lv_dept.
      MODIFY it_resb TRANSPORTING matkl dept where matnr = wa_mara-matnr.
    ENDSELECT.  
  ENDLOOP. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is throwing &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
wa_mara-matkl is unknown
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to implement in open SQL plz throw me light.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or please let me know best way to get this record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Oct 2010 07:49:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359155#M1541712</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-20T07:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Open Sql Between</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359156#M1541713</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;First, you fetch the Z Table Entries into an Internal Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_ztest,
        mat_from TYPE i,
        mat_to TYPE i,
        description TYPE string,
       END OF ty_ztest.

DATA: wa_test TYPE ty_ztest,
      it_test TYPE TABLE OF ty_ztest.

DATA: mat_grp TYPE i.

SELECT * FROM test INto TABLE it_test.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then Loop at this internal table and pass the Material Group No. in the Where Condition - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP at it_test INTO wa_test WHERE mat_grp BETWEEN wa_test-mat_from AND wa_test-mat_to.
  WRITE / wa_test-description.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Himanshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Oct 2010 08:03:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359156#M1541713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-20T08:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Open Sql Between</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359157#M1541714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In an Open SQL logical expression [BETWEEN|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_INTERVAL.htm] apply to a column on the left and two data objects for interval limits. so you cannot use this instruction here. use a &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_mara INTO wa_mara.
  SELECT dept FROM zmmt_mtgrp INTO lv_dept
    WHERE mktl_f LE wa_mara-matkl 
      AND mktl_t GE wa_mara-matkl.
    it_resb-matkl = wa_mara-matkl.
    it_resb-dept = lv_dept.
    MODIFY it_resb TRANSPORTING matkl dept WHERE matnr = wa_mara-matnr.
  ENDSELECT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also, if you have huge volumn of data, you can first fill a (SORTed) internal table with a SELECT FOR ALL ENTRIES and then use a READ TABLE (BINARY SEARCH) statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Oct 2010 08:26:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-between/m-p/7359157#M1541714</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2010-10-20T08:26:45Z</dc:date>
    </item>
  </channel>
</rss>

