<?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 Comparing Internal Tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-internal-tables/m-p/7090795#M1507160</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having 2 internal tables of same structure. I am retreiving the data from ZABC table based on some selection criteria.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{ SELECT * FROM ZABC&lt;/P&gt;&lt;P&gt;              INTO TABLE t_innet&lt;/P&gt;&lt;P&gt;              WHERE ytype = 'INNET'&lt;/P&gt;&lt;P&gt;             AND ybukrs IN s_bukrs&lt;/P&gt;&lt;P&gt;             AND ytlnr = p_ytlnr&lt;/P&gt;&lt;P&gt;             AND yjahr = p_gjahr&lt;/P&gt;&lt;P&gt;             AND ymonat = p_monat&lt;/P&gt;&lt;P&gt;             AND yreceiver IN s_kunnr. }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{ SELECT * FROM ZABC&lt;/P&gt;&lt;P&gt;           INTO TABLE t_sap&lt;/P&gt;&lt;P&gt;           WHERE ytype = 'SAP'&lt;/P&gt;&lt;P&gt;             AND ybukrs IN s_bukrs&lt;/P&gt;&lt;P&gt;             AND ytlnr = p_ytlnr&lt;/P&gt;&lt;P&gt;             AND yjahr = p_gjahr&lt;/P&gt;&lt;P&gt;             AND ymonat = p_monat&lt;/P&gt;&lt;P&gt;             AND yreceiver IN s_kunnr.}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I have to compare the entries of these 2 Internal tables based on the below criteria and update a field in table ZABC with status 1,2,3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Match item&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items in INNET but not in SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items in SAP but not in INNET&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items with different amounts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on this comparison we update the ZABC table, the field status with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	&lt;STRONG&gt;1 - OK - INNET = SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;	&lt;STRONG&gt;2 - DIF - INNET &amp;lt;&amp;gt; SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; 	&lt;STRONG&gt;3 - OPEN - Missing in INNET or SAP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to Compare the 2 tables in my scenario because I need to check each entry exists in both T_INNET &amp;amp; T_SAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If exists in T_INNET i need to check whether the entry is in T_SAP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If exists in T_SAP i need to check  whether the entry is in T_INNET.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&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;Sudhir&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Jul 2010 11:32:12 GMT</pubDate>
    <dc:creator>sudhir_uppalapati</dc:creator>
    <dc:date>2010-07-22T11:32:12Z</dc:date>
    <item>
      <title>Comparing Internal Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-internal-tables/m-p/7090795#M1507160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having 2 internal tables of same structure. I am retreiving the data from ZABC table based on some selection criteria.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{ SELECT * FROM ZABC&lt;/P&gt;&lt;P&gt;              INTO TABLE t_innet&lt;/P&gt;&lt;P&gt;              WHERE ytype = 'INNET'&lt;/P&gt;&lt;P&gt;             AND ybukrs IN s_bukrs&lt;/P&gt;&lt;P&gt;             AND ytlnr = p_ytlnr&lt;/P&gt;&lt;P&gt;             AND yjahr = p_gjahr&lt;/P&gt;&lt;P&gt;             AND ymonat = p_monat&lt;/P&gt;&lt;P&gt;             AND yreceiver IN s_kunnr. }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{ SELECT * FROM ZABC&lt;/P&gt;&lt;P&gt;           INTO TABLE t_sap&lt;/P&gt;&lt;P&gt;           WHERE ytype = 'SAP'&lt;/P&gt;&lt;P&gt;             AND ybukrs IN s_bukrs&lt;/P&gt;&lt;P&gt;             AND ytlnr = p_ytlnr&lt;/P&gt;&lt;P&gt;             AND yjahr = p_gjahr&lt;/P&gt;&lt;P&gt;             AND ymonat = p_monat&lt;/P&gt;&lt;P&gt;             AND yreceiver IN s_kunnr.}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I have to compare the entries of these 2 Internal tables based on the below criteria and update a field in table ZABC with status 1,2,3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Match item&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items in INNET but not in SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items in SAP but not in INNET&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Items with different amounts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on this comparison we update the ZABC table, the field status with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	&lt;STRONG&gt;1 - OK - INNET = SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;	&lt;STRONG&gt;2 - DIF - INNET &amp;lt;&amp;gt; SAP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; 	&lt;STRONG&gt;3 - OPEN - Missing in INNET or SAP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to Compare the 2 tables in my scenario because I need to check each entry exists in both T_INNET &amp;amp; T_SAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If exists in T_INNET i need to check whether the entry is in T_SAP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If exists in T_SAP i need to check  whether the entry is in T_INNET.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&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;Sudhir&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 11:32:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-internal-tables/m-p/7090795#M1507160</guid>
      <dc:creator>sudhir_uppalapati</dc:creator>
      <dc:date>2010-07-22T11:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Internal Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-internal-tables/m-p/7090796#M1507161</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 the sample code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT * FROM ZABC
INTO TABLE t_itab
WHERE ( ytype = 'INNET'
  or ytype = 'SAP' )
AND ybukrs IN s_bukrs
AND ytlnr = p_ytlnr
AND yjahr = p_gjahr
AND ymonat = p_monat
AND yreceiver IN s_kunnr.
  
  IF sy-subrc EQ 0.
    
    t_sap[] = t_itab[].
    
    t_innet[] = t_itab[].
    
    delete t_sap WHERE ytype EQ 'INNET'.
    
    delete t_innet WHERE ytype EQ 'SAP'.
    

  ENDIF.
  
  LOOP AT t_innet ASSIGNING &amp;lt;fs_innet&amp;gt;.
    
    READ TABLE t_sap ASSIGNING &amp;lt;fs_sap&amp;gt; WITH KEY (use ur key fields) = &amp;lt;fs_innet&amp;gt;-keyfields.
    
    IF sy-subrc EQ 0.
      
      IF &amp;lt;fs_innet&amp;gt;-item EQ &amp;lt;Fs_sap&amp;gt;-item.
        
        &amp;lt;fs_innet&amp;gt;-status = '1'.
        
        ELSE.
          
        &amp;lt;fs_innet&amp;gt;-status = '2'.  

      ENDIF.
      
      ELSE.
        
        &amp;lt;fs_innet&amp;gt;-status = '3'.  

    ENDIF.

  ENDLOOP.
  
    LOOP AT t_sap ASSIGNING &amp;lt;fs_sap&amp;gt;.
    
    READ TABLE t_innet ASSIGNING &amp;lt;fs_innet&amp;gt; WITH KEY item = &amp;lt;fs_sap&amp;gt;-item.
    
    IF sy-subrc EQ 0.
      
      IF &amp;lt;fs_innet&amp;gt;-item EQ &amp;lt;Fs_sap&amp;gt;-item.
        
        &amp;lt;fs_sap&amp;gt;-status = '1'.
        
        ELSE.
          
        &amp;lt;fs_sap&amp;gt;-status = '2'.  

      ENDIF.
      
      ELSE.
        
        &amp;lt;fs_sap&amp;gt;-status = '3'.  

    ENDIF.

  ENDLOOP.
  
  free t_itab.
  
  t_itab[] = t_sap.
  
  APPEND LINES OF t_innet[] to t_itab[].
  
* Now the updated values are in T_ITAB.. 
* Just update the ZABC table with the internal table T_ITAB.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 11:54:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-internal-tables/m-p/7090796#M1507161</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-22T11:54:34Z</dc:date>
    </item>
  </channel>
</rss>

