<?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: comparing two internal tables. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160664#M456989</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;&amp;lt;b&amp;gt;Comparing Internal Tables &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like other data objects, you can use internal tables as operands in logical expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.... &amp;lt;itab1&amp;gt; &amp;lt;operator&amp;gt; &amp;lt;itab2&amp;gt; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For &amp;lt;operator&amp;gt;, all operators listed in the table in Comparisons Between Data Types can be used (EQ, =, NE, &amp;lt;&amp;gt;, &amp;gt;&amp;lt;, GE, &amp;gt;=, LE, &amp;lt;=, GT, &amp;gt;, LT, &amp;lt;). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets ([ ]) after the table name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.

DATA: ITAB LIKE TABLE OF LINE,
JTAB LIKE TABLE OF LINE.

DO 3 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
  APPEND LINE TO ITAB.
ENDDO.

MOVE ITAB TO JTAB.

LINE-COL1 = 10. LINE-COL2 = 20.
APPEND LINE TO ITAB.

IF ITAB GT JTAB.
WRITE / 'ITAB GT JTAB'.
ENDIF.

APPEND LINE TO JTAB.

IF ITAB EQ JTAB.
WRITE / 'ITAB EQ JTAB'.
ENDIF.

LINE-COL1 = 30. LINE-COL2 = 80.
APPEND LINE TO ITAB.

IF JTAB LE ITAB.
WRITE / 'JTAB LE ITAB'.
ENDIF.

LINE-COL1 = 50. LINE-COL2 = 60.
APPEND LINE TO JTAB.

IF ITAB NE JTAB.
WRITE / 'ITAB NE JTAB'.
ENDIF.

IF ITAB LT JTAB.
WRITE / 'ITAB LT JTAB'.
ENDIF.

The output is: 

ITAB GT JTAB

ITAB EQ JTAB

JTAB LE ITAB

ITAB NE JTAB

ITAB LT JTAB

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB. &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 Rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 May 2007 08:07:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-02T08:07:19Z</dc:date>
    <item>
      <title>comparing two internal tables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160663#M456988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i am using CO_BO_OPR_OF_ORDER_GET function module to get the operation details corresponding to an order number. it imports two internal tables, a new one and an old one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose if i have updated a date of an operation and i want to check which particular operation's date has been updated, how do i do this? the internal tables imported have the old structure and the new structure, so i have to compare them and find out the operations whose dates differ..? is there any specific compare statement? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;having a loop inside another would take up processing time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 08:01:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160663#M456988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T08:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160664#M456989</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;&amp;lt;b&amp;gt;Comparing Internal Tables &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like other data objects, you can use internal tables as operands in logical expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.... &amp;lt;itab1&amp;gt; &amp;lt;operator&amp;gt; &amp;lt;itab2&amp;gt; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For &amp;lt;operator&amp;gt;, all operators listed in the table in Comparisons Between Data Types can be used (EQ, =, NE, &amp;lt;&amp;gt;, &amp;gt;&amp;lt;, GE, &amp;gt;=, LE, &amp;lt;=, GT, &amp;gt;, LT, &amp;lt;). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets ([ ]) after the table name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.

DATA: ITAB LIKE TABLE OF LINE,
JTAB LIKE TABLE OF LINE.

DO 3 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
  APPEND LINE TO ITAB.
ENDDO.

MOVE ITAB TO JTAB.

LINE-COL1 = 10. LINE-COL2 = 20.
APPEND LINE TO ITAB.

IF ITAB GT JTAB.
WRITE / 'ITAB GT JTAB'.
ENDIF.

APPEND LINE TO JTAB.

IF ITAB EQ JTAB.
WRITE / 'ITAB EQ JTAB'.
ENDIF.

LINE-COL1 = 30. LINE-COL2 = 80.
APPEND LINE TO ITAB.

IF JTAB LE ITAB.
WRITE / 'JTAB LE ITAB'.
ENDIF.

LINE-COL1 = 50. LINE-COL2 = 60.
APPEND LINE TO JTAB.

IF ITAB NE JTAB.
WRITE / 'ITAB NE JTAB'.
ENDIF.

IF ITAB LT JTAB.
WRITE / 'ITAB LT JTAB'.
ENDIF.

The output is: 

ITAB GT JTAB

ITAB EQ JTAB

JTAB LE ITAB

ITAB NE JTAB

ITAB LT JTAB

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB. &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 Rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 08:07:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160664#M456989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T08:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160665#M456990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Look at the below sample to code to compare the Internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT demo_int_tables_compare.

DATA: BEGIN OF line,
        col1 TYPE i,
        col2 TYPE i,
      END OF line.

DATA: itab LIKE TABLE OF line,
      jtab LIKE TABLE OF line.

DO 3 TIMES.
  line-col1 = sy-index.
  line-col2 = sy-index ** 2.
  APPEND line TO itab.
ENDDO.

MOVE itab TO jtab.

line-col1 = 10. line-col2 = 20.
APPEND line TO itab.

IF itab GT jtab.
  WRITE / 'ITAB GT JTAB'.
ENDIF.

APPEND line TO jtab.

IF itab EQ jtab.
  WRITE / 'ITAB EQ JTAB'.
ENDIF.

line-col1 = 30. line-col2 = 80.
APPEND line TO itab.

IF jtab LE itab.
  WRITE / 'JTAB LE ITAB'.
ENDIF.

line-col1 = 50. line-col2 = 60.
APPEND line TO jtab.

IF itab NE jtab.
  WRITE / 'ITAB NE JTAB'.
ENDIF.

IF itab LT jtab.
  WRITE / 'ITAB LT JTAB'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 08:08:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160665#M456990</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T08:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160666#M456991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;   i think u have to do field comparison .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if ( itab1-field1 = itab2-field1 ).&lt;/P&gt;&lt;P&gt;... do somehting....&lt;/P&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;&lt;P&gt; like this u have to ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 08:08:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160666#M456991</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T08:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160667#M456992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Maouli,&lt;/P&gt;&lt;P&gt; YOu have no other go.&lt;/P&gt;&lt;P&gt;YOu have to loop one internal table reading the other.&lt;/P&gt;&lt;P&gt;To make things a little better, you have to sort the tables by theor key fields and read using binary search.&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;loop at itab1.&lt;/P&gt;&lt;P&gt;read table itab2 with key field1 = itab1-field2.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;if itab1-date &amp;lt;&amp;gt; itab2-date.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Diferent dates&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 08:08:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/2160667#M456992</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T08:08:57Z</dc:date>
    </item>
  </channel>
</rss>

