<?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 compare 2 internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686159#M302087</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi everyone&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have 2 internal tables: itab and itrans&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itrans has the fields tabname, fieldname and it always contains the data&lt;/P&gt;&lt;P&gt;tabname    fieldname   value&lt;/P&gt;&lt;P&gt;FEBKO     ABSND      &lt;/P&gt;&lt;P&gt;FEBKO     AZDAT&lt;/P&gt;&lt;P&gt;FEBEP     KFMOD&lt;/P&gt;&lt;P&gt;FEBEP     KWBTR&lt;/P&gt;&lt;P&gt;FEBEP     PAKTO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the table itab has the fields &lt;/P&gt;&lt;P&gt;       kfmod &lt;/P&gt;&lt;P&gt;       kwbtr &lt;/P&gt;&lt;P&gt;       pakto &lt;/P&gt;&lt;P&gt;       absnd &lt;/P&gt;&lt;P&gt;       azdat &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i have to compare the lines in the table itab with those in the table itrans&lt;/P&gt;&lt;P&gt;with the corresponding values i.e&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the table itrans should be read in order as above and checked in table itab if the corresponding entry is not null, if the entry is null, the next record in the table itrans should be compared&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we compare when itrans-fieldname= ABSND, with itab-absnd, &lt;/P&gt;&lt;P&gt;if itab-absnd is null, move that line to another table&lt;/P&gt;&lt;P&gt;if its not null, continue comparing&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;compare when itrans-fieldname = AZDAT, with itab-azdat&lt;/P&gt;&lt;P&gt;if itab-azdat is null, move to anothe rtable&lt;/P&gt;&lt;P&gt;else compare with the next record in table itrans&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i really dont have an idea how to make this comparion in ABAP, can sombody help me out plz?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Nov 2006 07:57:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-21T07:57:42Z</dc:date>
    <item>
      <title>compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686159#M302087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi everyone&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have 2 internal tables: itab and itrans&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itrans has the fields tabname, fieldname and it always contains the data&lt;/P&gt;&lt;P&gt;tabname    fieldname   value&lt;/P&gt;&lt;P&gt;FEBKO     ABSND      &lt;/P&gt;&lt;P&gt;FEBKO     AZDAT&lt;/P&gt;&lt;P&gt;FEBEP     KFMOD&lt;/P&gt;&lt;P&gt;FEBEP     KWBTR&lt;/P&gt;&lt;P&gt;FEBEP     PAKTO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the table itab has the fields &lt;/P&gt;&lt;P&gt;       kfmod &lt;/P&gt;&lt;P&gt;       kwbtr &lt;/P&gt;&lt;P&gt;       pakto &lt;/P&gt;&lt;P&gt;       absnd &lt;/P&gt;&lt;P&gt;       azdat &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i have to compare the lines in the table itab with those in the table itrans&lt;/P&gt;&lt;P&gt;with the corresponding values i.e&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the table itrans should be read in order as above and checked in table itab if the corresponding entry is not null, if the entry is null, the next record in the table itrans should be compared&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we compare when itrans-fieldname= ABSND, with itab-absnd, &lt;/P&gt;&lt;P&gt;if itab-absnd is null, move that line to another table&lt;/P&gt;&lt;P&gt;if its not null, continue comparing&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;compare when itrans-fieldname = AZDAT, with itab-azdat&lt;/P&gt;&lt;P&gt;if itab-azdat is null, move to anothe rtable&lt;/P&gt;&lt;P&gt;else compare with the next record in table itrans&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i really dont have an idea how to make this comparion in ABAP, can sombody help me out plz?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 07:57:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686159#M302087</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-21T07:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686160#M302088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;TRY THIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITRANS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY FIELDNAME = ITRANS-FIELDNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;  &amp;lt; YOUR CONDITION OR MOVE TO ANOTHER TABLE&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SHIBA PRASAD DUTTA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 08:02:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686160#M302088</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-21T08:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686161#M302089</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;check this sample prog&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:begin of itab1 occurs 0,
f1(10) type c,
end of itab1.

data:begin of itab2 occurs 0,
f1(10) type c,
end of itab2.

data:begin of itab3 occurs 0,
f1(10) type c,
end of itab3.


itab1-f1 = 'abc'.
append itab1.

itab2-f1 = 'abc'.
append itab2.


if itab1[] = itab2[].
itab3[] = itab1[].
else.
write:/ 'tables are not same'. (or)
message e000(zz) with 'tables are not same'.
endif.

loop at itab3.
write:/ itab3-f1.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT t_1.
READ TABLE t_2 WITH KEY f1 = t_1-f1
f2 = t_1-f2.
IF sy-subrc = 0.
MOVE-CORRESPONDING t_1 TO t_3.
APPEND t_3.
CLEAR t_3.
ELSE.
* raise error
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;VJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 08:02:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686161#M302089</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-21T08:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686162#M302090</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;The best way is using the ASSIGN COMPONENT OF... statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols:&lt;/P&gt;&lt;P&gt;  &amp;lt;itrans&amp;gt; like line of itrans,&lt;/P&gt;&lt;P&gt;  &amp;lt;field&amp;gt; type any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itrans assigning &amp;lt;itrans&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign component &amp;lt;itrans&amp;gt;-fieldname of structure &amp;lt;itrans&amp;gt; to &amp;lt;field&amp;gt;.&lt;/P&gt;&lt;P&gt;  if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    if &amp;lt;field&amp;gt; is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Do something here...&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;P&gt;&lt;/P&gt;&lt;P&gt;I didn't syntax check the code above, etc but that's pretty much what you'll need to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 08:08:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686162#M302090</guid>
      <dc:creator>michael-john_turner</dc:creator>
      <dc:date>2006-11-21T08:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686163#M302091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no its not that&lt;/P&gt;&lt;P&gt;if a corresponding entry is not found, i have to compare the next record in itrans&lt;/P&gt;&lt;P&gt;for eg.&lt;/P&gt;&lt;P&gt;loop at itab&lt;/P&gt;&lt;P&gt; read table itrans with key fieldname = itab-absnd&lt;/P&gt;&lt;P&gt; if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;  if itab-absnd is null&lt;/P&gt;&lt;P&gt;  move to another table&lt;/P&gt;&lt;P&gt; else&lt;/P&gt;&lt;P&gt;***&lt;STRONG&gt;i need to compare the next record in table itrans&lt;/STRONG&gt;****and this is where i dnt know how to proceed&lt;/P&gt;&lt;P&gt;i need to compare itrans-fieldname with the remaining records in table itab&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>Tue, 21 Nov 2006 08:10:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686163#M302091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-21T08:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686164#M302092</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;create a table itab1 which is of same structure as itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;loop at itrans.&lt;/P&gt;&lt;P&gt;case itrans-fieldname.&lt;/P&gt;&lt;P&gt;when 'ABSND'.&lt;/P&gt;&lt;P&gt;if  itab-absnd eqspace.&lt;/P&gt;&lt;P&gt;move-corresponding  itab to itab1.&lt;/P&gt;&lt;P&gt;append itab1.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;when 'AZDAT'.&lt;/P&gt;&lt;P&gt;if itab-azdat eq space.&lt;/P&gt;&lt;P&gt;move-corresponding  itab to itab1.&lt;/P&gt;&lt;P&gt;append itab1.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now your itab1 contains the required entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 08:12:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686164#M302092</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2006-11-21T08:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: compare 2 internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686165#M302093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi anjali,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check out this code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COL1 TYPE I,&lt;/P&gt;&lt;P&gt;COL2 TYPE I,&lt;/P&gt;&lt;P&gt;END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ITAB LIKE TABLE OF LINE,&lt;/P&gt;&lt;P&gt;JTAB LIKE TABLE OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 3 TIMES.&lt;/P&gt;&lt;P&gt;LINE-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;LINE-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;  APPEND LINE TO ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE ITAB TO JTAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ITAB GT JTAB.&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt; ANY OPERATION&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now in ur case if all the records are not null then do nothing else shift to another table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;simple steps:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. transfer ur itab table into a new internal table which has the same structure as itrans.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. now sort the both tables (itans and new internal table) with unique key fields(i.e. no&lt;/P&gt;&lt;P&gt;repeated values in the table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. now compare both the tables with 'eq' operator&lt;/P&gt;&lt;P&gt;  if equals then do nothing ( or whatelse u want to do)&lt;/P&gt;&lt;P&gt;  else move the records into another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward me with the points if u find  answer helpful to u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikram dev&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 09:24:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-2-internal-tables/m-p/1686165#M302093</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-21T09:24:02Z</dc:date>
    </item>
  </channel>
</rss>

