<?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: Regarding Logic for comparing 3 internal tables data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-logic-for-comparing-3-internal-tables-data/m-p/1212736#M133989</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;You can loop at the first table and use the READ statement for the next two tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_pdata1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  read table i_pdata2 with key ????&lt;/P&gt;&lt;P&gt;  if ys-subrc = 0.&lt;/P&gt;&lt;P&gt;    read table i_pdata3 with key ???&lt;/P&gt;&lt;P&gt;    if sy-subrc = .&lt;/P&gt;&lt;P&gt;      move record into i_pdata.&lt;/P&gt;&lt;P&gt;      append i_pdata.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For performance improvement, you can declare i_pdata2 and i_pdata3 as SORTED tables, with KEY as the columns with which you are going to READ the tables and add the BINARY SEARCH option to the READ statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was wondering, why can't write you one SELECT joining 3 tables and dumping the data directly into i_pdata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : Please mark the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Apr 2006 15:56:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-04-10T15:56:53Z</dc:date>
    <item>
      <title>Regarding Logic for comparing 3 internal tables data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-logic-for-comparing-3-internal-tables-data/m-p/1212735#M133988</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;I have a issue related to &amp;lt;b&amp;gt;Logic for comparing 3 internal tables data&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had decalred 3 internal Tables &amp;amp; Final Internal Tables as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DATA: BEGIN OF i_pdata1 OCCURS 0,&lt;/P&gt;&lt;P&gt;        zzexgen LIKE zexport_class-zzexgen,&lt;/P&gt;&lt;P&gt;        zzalnum LIKE zexport_class-zzalnum,&lt;/P&gt;&lt;P&gt;        zzembgr LIKE zexport_class-zzembgr,&lt;/P&gt;&lt;P&gt;        zzsecgk LIKE zexport_class-zzsecgk,&lt;/P&gt;&lt;P&gt;      END OF i_pdata1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF i_pdata2 OCCURS 0,&lt;/P&gt;&lt;P&gt;        zzexgen LIKE zexport_customer-zzexgen,&lt;/P&gt;&lt;P&gt;        zzkunnr LIKE zexport_customer-zzkunnr,&lt;/P&gt;&lt;P&gt;      END OF i_pdata2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF i_pdata3 OCCURS 0,&lt;/P&gt;&lt;P&gt;        zzexgen LIKE zexport_country-zzexgen,&lt;/P&gt;&lt;P&gt;        zzgenla LIKE zexport_country-zzgenla,&lt;/P&gt;&lt;P&gt;      END OF i_pdata3.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And Final Internal Table as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DATA: BEGIN OF i_pdata OCCURS 0,&lt;/P&gt;&lt;P&gt;        zzexgen LIKE zexport_header-zzexgen,&lt;/P&gt;&lt;P&gt;      END OF i_pdata.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now what i have to do is to populate all the first 3 internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then findout common Entries for [ZZEXGEN] field in all the 3 fields and push them to i_pdata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And make use those ZZEXGEN field values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had written following select statements to REtrieve and fill all the first 3 internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

&amp;lt;b&amp;gt;  SELECT zzexgen
         zzalnum
         zzembgr
         zzsecgk
         FROM zexport_class
         INTO TABLE i_pdata1
         WHERE zzalnum = i_data-alnum AND
               zzembgr = i_data-embgr AND
               zzsecgk = i_data-secgk.

  IF sy-subrc EQ 0.
  ENDIF.

  SELECT zzexgen
         zzkunnr
         FROM zexport_customer
         INTO TABLE i_pdata2
         WHERE zzkunnr = i_data-kunnr.

  IF sy-subrc EQ 0.
  ENDIF.

  SELECT zzexgen
         zzgenla
         FROM zexport_country
         INTO TABLE i_pdata3
         WHERE zzgenla = i_data-land1.

  IF sy-subrc EQ 0.
  ENDIF.&amp;lt;/b&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i need to write a logic to find out Common entries for ZZEXGEN field in all 3 internal tables and push them to final internal table I_PDATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody tell me the easiest logic to do so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Ex for reference : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Table I_PDATA1 would have Ext_1 and Ext_2.&lt;/P&gt;&lt;P&gt;Internal Table I_PDATA2 would have Ext_1 and Ext_2.&lt;/P&gt;&lt;P&gt;Internal Table I_PDATA3 would have Ext_1, Ext_2 &amp;amp; Ext_3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now final internal table[I_PDATA] values should be &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ext_1 and Ext_2.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody tell me the logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Rayeez.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 15:47:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-logic-for-comparing-3-internal-tables-data/m-p/1212735#M133988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T15:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Logic for comparing 3 internal tables data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-logic-for-comparing-3-internal-tables-data/m-p/1212736#M133989</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;You can loop at the first table and use the READ statement for the next two tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_pdata1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  read table i_pdata2 with key ????&lt;/P&gt;&lt;P&gt;  if ys-subrc = 0.&lt;/P&gt;&lt;P&gt;    read table i_pdata3 with key ???&lt;/P&gt;&lt;P&gt;    if sy-subrc = .&lt;/P&gt;&lt;P&gt;      move record into i_pdata.&lt;/P&gt;&lt;P&gt;      append i_pdata.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For performance improvement, you can declare i_pdata2 and i_pdata3 as SORTED tables, with KEY as the columns with which you are going to READ the tables and add the BINARY SEARCH option to the READ statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was wondering, why can't write you one SELECT joining 3 tables and dumping the data directly into i_pdata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : Please mark the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 15:56:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-logic-for-comparing-3-internal-tables-data/m-p/1212736#M133989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T15:56:53Z</dc:date>
    </item>
  </channel>
</rss>

