<?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: Select Query Problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851578#M360637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul , &lt;/P&gt;&lt;P&gt;  What i would suggest is keep the select statement as it is , then loop on your internal table where document type is CT, read the table and find if there is any record with the same document number , material and   document type CT1 , if it is there then delete the record from internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code will look some thing like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_ZEXC_REC  WHERE RDOCTYP = 'CT'.
READ TABLE it_ZEXC_REC INTO WA_1 
WITH KEY DOCNO   =  it_ZEXC_RECDOCNO 
                 RDOCTYP = 'CT1'
                 MATNR = it_ZEXC_REC-MATNR.
IF SY-SUBRC = 0.
DELETE TABLE it_ZEXC_REC  INDEX SY-TABIX.
CLEAR WA_1
ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Jan 2007 06:56:14 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-25T06:56:14Z</dc:date>
    <item>
      <title>Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851575#M360634</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;&lt;/P&gt;&lt;P&gt;I am selecting values from a table zexc_rec using the query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from zexc_rec into table it_ZEXC_REC&lt;/P&gt;&lt;P&gt;      where&lt;/P&gt;&lt;P&gt;      LIFNR in S_LIFNR and&lt;/P&gt;&lt;P&gt;      DOCNO in S_DOCNO and&lt;/P&gt;&lt;P&gt;      RDOCTYP in S_RDTYP and&lt;/P&gt;&lt;P&gt;      DOCTYP EQ S_DOCTYP AND&lt;/P&gt;&lt;P&gt;      DATE1 in S_DATE1 and&lt;/P&gt;&lt;P&gt;      MATNR EQ S_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I am having condition that I have to check whether any other row with same document no., same material no  and document type as ' CT ' exist there in the table zexc_rec, if it is there then I have to select the row with the doctyp as ' CT' otherwise I have to select the row with doctype as 'CT1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest what modifications I should do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:46:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851575#M360634</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851576#M360635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try as follows:&lt;/P&gt;&lt;P&gt;select * from zexc_rec into table it_ZEXC_REC&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;LIFNR in S_LIFNR and&lt;/P&gt;&lt;P&gt;DOCNO in S_DOCNO and&lt;/P&gt;&lt;P&gt;RDOCTYP in S_RDTYP and&lt;/P&gt;&lt;P&gt;DOCTYP EQ S_DOCTYP AND&lt;/P&gt;&lt;P&gt;DATE1 in S_DATE1 and&lt;/P&gt;&lt;P&gt;MATNR EQ S_MATNR&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt; and doctyp in ( 'CT' , 'CT1' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort table it_zexc_rec by matnr.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from it_zexc_rec comparing matnr.&lt;/P&gt;&lt;P&gt; &amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Subramanian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:50:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851576#M360635</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851577#M360636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Are the document number (LIFNR) and doc type (DOCTYP) both primary keys in the table 'zexc_rec'.. &lt;/P&gt;&lt;P&gt;If so u will get only one value..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose that LIFNR is surely a key field..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If DOCTYP is not a key field , mention both values CT and CT1 in the selection parameters S_DOCTYP ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will fetch all the records for the document number with all the corresponding doc types..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Rajiv&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:55:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851577#M360636</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851578#M360637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul , &lt;/P&gt;&lt;P&gt;  What i would suggest is keep the select statement as it is , then loop on your internal table where document type is CT, read the table and find if there is any record with the same document number , material and   document type CT1 , if it is there then delete the record from internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code will look some thing like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_ZEXC_REC  WHERE RDOCTYP = 'CT'.
READ TABLE it_ZEXC_REC INTO WA_1 
WITH KEY DOCNO   =  it_ZEXC_RECDOCNO 
                 RDOCTYP = 'CT1'
                 MATNR = it_ZEXC_REC-MATNR.
IF SY-SUBRC = 0.
DELETE TABLE it_ZEXC_REC  INDEX SY-TABIX.
CLEAR WA_1
ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:56:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851578#M360637</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851579#M360638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Subramanian ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can u please tell how to delete the adjacent duplicates by comparing matnr.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:56:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851579#M360638</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851580#M360639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul , &lt;/P&gt;&lt;P&gt;  As a contuination of my previous post , i have a doubt , in the select there is a field RDOCTYP in the where clause , is this the document type CT , CT1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 06:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851580#M360639</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T06:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851581#M360640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just copy this code in SE38 and run it , you will understand how to delete the adjacent duplicates  by comparing a key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;report  zkun_del1                               .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of warea ,&lt;/P&gt;&lt;P&gt;        a type i,&lt;/P&gt;&lt;P&gt;        b type c,&lt;/P&gt;&lt;P&gt;        m type i,&lt;/P&gt;&lt;P&gt;        end of warea.&lt;/P&gt;&lt;P&gt;data : j type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data itab like table of warea with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;j = 5 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while j &amp;gt; 0.&lt;/P&gt;&lt;P&gt;itab-a  = itab-a + 1.&lt;/P&gt;&lt;P&gt;itab-b = 'b'.&lt;/P&gt;&lt;P&gt;itab-m = itab-m + 1.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;j = j - 1.&lt;/P&gt;&lt;P&gt;endwhile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write 78.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;write:/ itab-a,  itab-b ,  itab-m.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-a  = itab-a + 1.&lt;/P&gt;&lt;P&gt;itab-b = 'c'.&lt;/P&gt;&lt;P&gt;itab-m = itab-m + 1.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;delete adjacent duplicates from itab comparing b.&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;write:/ itab-a,  itab-b ,  itab-m.&lt;/P&gt;&lt;P&gt;endloop.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Here, I have defined an internal table . Then I have created some entries in internal table and print them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After that I have delted the adjacent duplicates and again print the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the similar way, you can use this concept for your pupose as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;delete adjacent duplicates from &amp;lt;internal table name&amp;gt; comparing matnr.&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Kunal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jan 2007 09:10:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-problem/m-p/1851581#M360640</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-25T09:10:08Z</dc:date>
    </item>
  </channel>
</rss>

