<?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: Modify DB in chunk in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538787#M1427672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try like below also,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: itab TYPE TABLE OF mara,
           wa TYPE mara,
           cnt TYPE i VALUE 1000.

SELECT * FROM mara INTO TABLE itab WHERE vpsta = 'K'.

LOOP AT itab INTO wa.
  wa-vpsta = 'KL'.
  MODIFY mara FROM wa.
  IF sy-tabix = cnt.
    CALL FUNCTION 'DB_COMMIT'.
    cnt = cnt + 1000.
  ENDIF.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Jan 2010 09:32:31 GMT</pubDate>
    <dc:creator>awin_prabhu</dc:creator>
    <dc:date>2010-01-04T09:32:31Z</dc:date>
    <item>
      <title>Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538783#M1427668</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;I have large internal table (like 1000000 records ) and i want to modify DB table from it ,&lt;/P&gt;&lt;P&gt;what i want is to do the modify in chunk i.e. to do commit after 1000 recorded each time .&lt;/P&gt;&lt;P&gt;what is the best way to do that ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:05:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538783#M1427668</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T09:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538784#M1427669</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;It depends on how your report is arranged in order to improve the performance, anyway if I need to considere the internal table only, probably it should create a package with 1000 hits:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DESCRIBE TABLE ITAB_MAIN LINES TOT_RECORDS.

FROM_INDEX = 1.
IF TOT_RECORDS &amp;gt; 1000.
  TO_INDEX      = 1000.
ELSE.
  TO_INDEX      = TOT_RECORDS.
ENDIF.

DO.
  APPEND LINES OF ITAB_MAIN TO ITAB FROM FROM_INDEX TO TO_INDEX.
  UPDATE &amp;lt;TABLE&amp;gt; FROM ITAB.
  COMMIT WORK.
  FROM_INDEX = TO_INDEX + 1.
  IF FROM_INDEX &amp;gt; TOT_RECORDS.
    EXIT.
  ENDIF.
  TO_INDEX = TO_INDEX + 1000.
   IF FROM_INDEX &amp;gt; TOT_RECORDS.
      FROM_INDEX = TOT_RECORDS.
   ENDIF.
   REFRESH ITAB.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:15:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538784#M1427669</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T09:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538785#M1427670</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 move 1000 records from your internal table to temporary internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can move records from this temporary internal table to database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:20:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538785#M1427670</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T09:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538786#M1427671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Max,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;I check it and let you know .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some additional questions ,&lt;/P&gt;&lt;P&gt;1. to do the modify in chunk it is good approach ?&lt;/P&gt;&lt;P&gt;2. i use modify from table in my program do i need to do read before update and just to modify the changes records &lt;/P&gt;&lt;P&gt;3. the DO  statements  is not risky (like go to infinite loop ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot and best regards&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538786#M1427671</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T09:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538787#M1427672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try like below also,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: itab TYPE TABLE OF mara,
           wa TYPE mara,
           cnt TYPE i VALUE 1000.

SELECT * FROM mara INTO TABLE itab WHERE vpsta = 'K'.

LOOP AT itab INTO wa.
  wa-vpsta = 'KL'.
  MODIFY mara FROM wa.
  IF sy-tabix = cnt.
    CALL FUNCTION 'DB_COMMIT'.
    cnt = cnt + 1000.
  ENDIF.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:32:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538787#M1427672</guid>
      <dc:creator>awin_prabhu</dc:creator>
      <dc:date>2010-01-04T09:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538788#M1427673</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;One more thing when i try to use append lines i get this error &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    APPEND LINES OF it_fil_us_data TO lt_chunk_table&lt;/P&gt;&lt;P&gt;    FROM  lv_from_index TO lv_to_index   .&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;Chris&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;".", "ASSIGNING &amp;lt;fs&amp;gt;", "REFERENCE INTO data-reference", or "ASSIGNING		&lt;/P&gt;&lt;P&gt;&amp;lt;fs&amp;gt; CASTING" expected after "LT_CHUNK_TABLE".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 09:58:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538788#M1427673</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T09:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538789#M1427674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Max,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ignore my last post &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the solution is  &lt;/P&gt;&lt;P&gt;APPEND LINES OF  it__fil_usrs_data&lt;/P&gt;&lt;P&gt;    FROM  lv_from_index TO lv_to_index TO lt_chunk_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you have some answers to my previous questions ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards &lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 10:07:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538789#M1427674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T10:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538790#M1427675</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 some additional questions ,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1. to do the modify in chunk it is good approach ?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY is INSERT+UPDATE, that means if a record in internal table doesn't exist it'll be inserted: that can be or can't be a risk: I don't know your goal.&lt;/P&gt;&lt;P&gt;I prefer to use UPDATE if I needs to update existing record only, so if perpahs a wrong record is loaded in the internal table it won't be inserted, and so I can avoid to do a select to check if a record exists or doesn't exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you doesn't need to care about it and so u need to insert and update a record: MODIFY is better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;2. i use modify from table in my program do i need to do read before update and just to modify the changes records&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the concept below: if you need to change the existing records only, u make sure the record uploaded in the internal tables are in dictionary table too: how to do it depends on your program, i.e. how u've uploaded them, else u should check it before using MODIFY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;3. the DO statements is not risky (like go to infinite loop ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every time a do cycle is used it needs to use a condition exit: in my sample I've used a counter... else a infinite loop is sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 10:45:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538790#M1427675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T10:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538791#M1427676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, maybe it's just me, but I for one would like to know first if this is a standard SAP table or a custom table. Or to put it more general, does this DB table have any direct relationship (header and item table for example) with other DB tables. So when updating (modifying) one table, do you 'mess up' the referential integrity?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 11:01:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538791#M1427676</guid>
      <dc:creator>Sm1tje</dc:creator>
      <dc:date>2010-01-04T11:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Modify DB in chunk</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538792#M1427677</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 table is stand alone  ץ&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;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2010 12:32:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-db-in-chunk/m-p/6538792#M1427677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-04T12:32:12Z</dc:date>
    </item>
  </channel>
</rss>

