<?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 Application server file and internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624947#M279287</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iam new to the world of ABAP. I have a requirement wherein i need to compare data in a internal table and that of the file. I need to extract the delta records( ie the record is found in the internal table but not in the file and vice versa ) and put it in another internal table. Which is the best way to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Awaiting quick reply. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nirmal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Sep 2006 08:22:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-24T08:22:41Z</dc:date>
    <item>
      <title>Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624947#M279287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iam new to the world of ABAP. I have a requirement wherein i need to compare data in a internal table and that of the file. I need to extract the delta records( ie the record is found in the internal table but not in the file and vice versa ) and put it in another internal table. Which is the best way to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Awaiting quick reply. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nirmal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 08:22:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624947#M279287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-24T08:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624948#M279288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lets say your data in internal table is  ITAB1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and your file data in ITAB2.( i am assuming you know the way how to read the records of a file from application server/presentation server,if not let us know).&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 LINE = ITAB1-LINE.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;*--ITAB1 RECORD NOT available in ITAB2,so populate to another internal table.&lt;/P&gt;&lt;P&gt;    ITAB3 = ITAB1.&lt;/P&gt;&lt;P&gt;    APPEND ITAB3.&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;*--The similar way you can loop ITAB2 and do a search for ITAB1 and if not found populate that record to ITAB3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1,itab2,itab3 record structure can be like,&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF ITAB1 OCCURS 0,&lt;/P&gt;&lt;P&gt;         LINE(1000) TYPE C,&lt;/P&gt;&lt;P&gt;       END OF ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Srikanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 08:28:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624948#M279288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-24T08:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624949#M279289</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;How to check if a record is in the file and in the table depends on how you have defined the structure (of table and file) anyway this is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: FILE(80).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ITAB OCCURS 0,&lt;/P&gt;&lt;P&gt;        FIELD1,&lt;/P&gt;&lt;P&gt;        FIELD2,&lt;/P&gt;&lt;P&gt;        FIELDN,&lt;/P&gt;&lt;P&gt;        MARK,&lt;/P&gt;&lt;P&gt;      END   OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: WA LIKE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;  DO.&lt;/P&gt;&lt;P&gt;    READ DATASET FILE INTO WA.&lt;/P&gt;&lt;P&gt;    IF SY-SUBRC &amp;lt;&amp;gt; 0. EXIT. ENDIF.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    CLEAR ITAB.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    LOOP AT ITAB WHERE MARK = SPACE.&lt;/P&gt;&lt;P&gt;      IF ITAB = WA.&lt;/P&gt;&lt;P&gt;        ITAB-MARK = 'X'.&lt;/P&gt;&lt;P&gt;        MODIFY ITAB.&lt;/P&gt;&lt;P&gt;        EXIT.&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;    IF ITAB-MARK = SPACE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;----&amp;gt; Create delta with file record (WA)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    ENDIF.    &lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here all records with field MARK is space are the records of internal &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;table not in the file &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT ITAB WHERE MARK = SPACE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;----&amp;gt; Create delta  with table record (ITAB)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 08:48:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624949#M279289</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-24T08:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624950#M279290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nimal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First read the file into your itab. For comparison you can use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_s_itab_di.  
INCLUDE TYPE struc_a.
TYPES: CHIND  TYPE bu_chind.
TYPES: END OF ty_s_itab_di.
TYPES: ty_t_itab_di  TYPE STANDARD TABLE OF ty_s_itab_di 
                     WITH DEFAULT KEY.
DATA:  
  gt_itab_old  TYPE ty_t_itab_di,&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  gt_itab_new  TYPE ty_t_itab_di.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Very important: sort you itabs either by all key fields or by all fields.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call function CHANGEDOCUMENT_PREPARE_TABLES with the following parameters:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;- CHECK_INDICATOR = ' ' &lt;/P&gt;&lt;P&gt;- TABLE_NEW = gt_Itab_new&lt;/P&gt;&lt;P&gt;- TABLE_OLD = gt_itab_old&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 09:36:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624950#M279290</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-09-24T09:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624951#M279291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply. I want to also extract the changed records( i.e. the record is present in both the internal tables current and old. But some contents of current has changed with respect to the old internal table for the same record). What shall be done in this case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nirmal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 15:07:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624951#M279291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-24T15:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Application server file and internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624952#M279292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nirmal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module CHANGEDOCUMENT_PREPARE_TABLES returns also this result: in this case the corresponding entry in gt_itab_new has CHIND = 'U'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;   Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: I add the documentation of the TABLES parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; Table contains the changed data

     The table structure must begin with the structure specified under
     TABLENAME and an additional processing flag (TYPE C, length 1).

     The table must be passed sorted by key.

     During compression, identical lines in TABLE_OLD and TABLE_NEW are
     deleted and the processing flag set. The following cases are
     distinguished:

     o   Lines which exist with table key in TABLE_NEW, but not in TABLE_OLD:
         Processing flag = "I" for INSERT.

     o   Lines which exist with table key in TABLE_NEW and in TABLE_OLD, the
         contents of the TABLENAME structure fields in TABLE_NEW is not the
         same as in TABLE_OLD: Processing flag = "U" for UPDATE.

     o   Lines which exist with table key in TABLE_NEW and in TABLE_OLD, the
         contents of the TABLENAME structure fields in TABLE_NEW is the same
         as in TABLE_OLD: Delete the line in TABLE_NEW, Delete the line in
         TABLE_OLD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Sep 2006 18:53:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-application-server-file-and-internal-table/m-p/1624952#M279292</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-09-24T18:53:08Z</dc:date>
    </item>
  </channel>
</rss>

