<?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 Two table comparisions (logic problem) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959852#M1489773</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose I have a table itab1 with two cols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;col1         col2
A            0001
A            0002
A            0004
B            0001
B            0002
B            0003
B            0004&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;second table itab2 has values &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001&lt;/P&gt;&lt;P&gt;0002&lt;/P&gt;&lt;P&gt;0003&lt;/P&gt;&lt;P&gt;0004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to delete all rows from itab1 based on itab 2 which does not hav all the values in itab1 from itab2 based on cl1 n col2 both &lt;/P&gt;&lt;P&gt;e.g in this case only this shud remain&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;B            0001
B            0002
B            0003
B            0004&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Karan Chopra on Jun 21, 2010 3:16 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Karan Chopra on Jun 21, 2010 3:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jun 2010 09:40:54 GMT</pubDate>
    <dc:creator>Karan_Chopra_</dc:creator>
    <dc:date>2010-06-21T09:40:54Z</dc:date>
    <item>
      <title>Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959852#M1489773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose I have a table itab1 with two cols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;col1         col2
A            0001
A            0002
A            0004
B            0001
B            0002
B            0003
B            0004&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;second table itab2 has values &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001&lt;/P&gt;&lt;P&gt;0002&lt;/P&gt;&lt;P&gt;0003&lt;/P&gt;&lt;P&gt;0004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to delete all rows from itab1 based on itab 2 which does not hav all the values in itab1 from itab2 based on cl1 n col2 both &lt;/P&gt;&lt;P&gt;e.g in this case only this shud remain&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;B            0001
B            0002
B            0003
B            0004&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Karan Chopra on Jun 21, 2010 3:16 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Karan Chopra on Jun 21, 2010 3:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 09:40:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959852#M1489773</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-06-21T09:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959853#M1489774</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;Karan wrote...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
second table itab2 has values 

0001
0002
0003
0004

i want to delete all rows from itab1 based on itab 2 which does not hav all the values in itab1 from itab2 based on cl1 n col2 both 
e.g in this case only this shud remain
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But Itab2 does not have cl1 n col2 .&lt;/P&gt;&lt;P&gt;Can you please clarify me on this point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;DKS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 09:50:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959853#M1489774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T09:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959854#M1489775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes itab 2 does not hav col1 value s&lt;/P&gt;&lt;P&gt;the thing is all the values of itab2 here shud exist in itab1 for same col1 value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as here col1 value B has all 0001 to 0004 values so it is considered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 09:55:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959854#M1489775</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-06-21T09:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959855#M1489776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please search the SCN before Posting. Many threads available in SCN related to this and refer the SCN rules before Posting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Regards,&lt;/P&gt;&lt;P&gt;Sumodh.P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:21:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959855#M1489776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T10:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959856#M1489777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But on what criteria to search SCN&lt;/P&gt;&lt;P&gt;as this is very specific thing and I donot by what search criteria I should search&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:28:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959856#M1489777</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-06-21T10:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959857#M1489778</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;Try anything like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of itab1 occurs 0,
      col1(1),
      col2(4),
      end of itab1.
data: begin of itab2 occurs 0,
      col2(4),
      end of itab2.
data: itab3 like itab2 occurs 0 with header line.
data: begin of itab4 occurs 0,
      col1(1),
      end of itab4.
itab1-col1 = 'A'. itab1-col2 = '0001'. append itab1.
itab1-col1 = 'A'. itab1-col2 = '0002'. append itab1.
itab1-col1 = 'A'. itab1-col2 = '0004'. append itab1.
itab1-col1 = 'B'. itab1-col2 = '0001'. append itab1.
itab1-col1 = 'B'. itab1-col2 = '0002'. append itab1.
itab1-col1 = 'B'. itab1-col2 = '0003'. append itab1.
itab1-col1 = 'B'. itab1-col2 = '0004'. append itab1.

itab2-col2 = '0001'. append itab2.
itab2-col2 = '0002'. append itab2.
itab2-col2 = '0003'. append itab2.
itab2-col2 = '0004'. append itab2.

sort: itab1, itab2.

loop at itab1.
  at new col1.
    refresh itab3.
  endat.
  itab3-col2 = itab1-col2. append itab3.
  at end of col1.
    sort itab3.
    if itab3[] &amp;lt;&amp;gt; itab2[].
      clear itab4. itab4-col1 = itab1-col1.
      append itab4.
    endif.
  endat.
endloop.
loop at itab4.
  delete itab1 where col1 = itab4-col1.
endloop.

loop at itab1.
  write: itab1-col1, itab1-col2.
  new-line.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959857#M1489778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T10:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959858#M1489779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Karan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code will move the records from itab1 to itab3 where the value of col2 is present in itab2&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: lw_tabix type sytabix.
* Declare itab3 like itab1
loop at itab1 into wa_1.
* Search the value of col2 in table itab1
read table itab2 into wa_2 with key col1 = wa_1-col2.
if sy-subrc eq 0.
* if found then move the record to itab3
Move wa_2 to wa_3.
append wa_3 to itab3
endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now itab3 will hold the desired records&lt;/P&gt;&lt;P&gt;This will solve your problem...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;DKS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:45:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959858#M1489779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T10:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959859#M1489780</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;Try this logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;type : begin of ty_tab3,
         col1 type itab1-col1.
       end of ty_tab3.
data : itab3 type standard table of ty_tab3.
       wa3   type ty_tab3.
l_no(5) type n.
l_rec(5) type n.
l_col1 type itab1-col1.
delete adjacent duplicates from itab1 comparing all fields.
describle table itab2 lines l_no.
sort itab1 by col1.
move 0 to l_rec.
loop at itab1 into wa.
   if col1 ne l_col1.
      if l_rec eq l_no.
        clear : wa3, l_rec.
	move l_col1 to wa3-col1.
        append wa3 to itab3.
      endif.
   endif.
   add 1 to l_rec.
   move wa-col1 to l_col1.   	   
endloop.
if l_rec eq l_no.
  clear : wa3, l_rec.
  move l_col1 to wa3-col1.
  append wa3 to itab3.
endif.
loop at itab3 into wa3.
   loop at itab1 where col1 = wa3-col.
     write:/ itab1-col1 itab1-col2.
   endloop.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:54:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959859#M1489780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T10:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959860#M1489781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Please elaborate your question . From your description your query is not clear.&lt;/P&gt;&lt;P&gt;Do you want to delete the first occurrence of repeated entries from first table?&lt;/P&gt;&lt;P&gt;Please specify so that I can help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Uma Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 10:58:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959860#M1489781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-21T10:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Two table comparisions (logic problem)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959861#M1489782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this logic: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* Populate the master key based on ITAB2, before that SORT ITAB2
SORT ITAB2.
CONCATENATE LINES OF itab2 INTO v_master_key.

* Remember to SORT ITAB1
SORT itab1 BY col1 col2.

LOOP AT itab1.
  itab3 = itab1.
  APPEND itab3.
  CONCATENATE v_key itab1-col2 INTO v_key.
  AT END OF col1.
    CONDENSE v_key NO-GAPS.
    IF v_key NE v_master_key.
*     We're not interested in these records, delete them      
      DELETE itab3 WHERE col1 = itab1-col1.
    ENDIF.
    CLEAR: v_key. "Don't forget to clear the key
  ENDAT.
ENDLOOP.

LOOP AT itab3.
  WRITE: / itab3.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&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;PS: I took Dzed's code as reference &amp;amp; tweaked it as per my logic. Apologies to Dzed &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 11:01:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/two-table-comparisions-logic-problem/m-p/6959861#M1489782</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-06-21T11:01:58Z</dc:date>
    </item>
  </channel>
</rss>

