<?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: adding field values from internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366812#M181324</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt; we should NOT use MODIFY in your case, as  MODIFY will be used for Inserting/changing records.&lt;/P&gt;&lt;P&gt;if the record does not exists, it will insert the record.&lt;/P&gt;&lt;P&gt;if the record exists, it will change the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but UPDATE will do only works if the matching record exists in the database, it wont create at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the description of both(copied from sap library)&lt;/P&gt;&lt;P&gt;Changing Lines &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Open SQL statement for changing data in a database table is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE &amp;lt;target&amp;gt; &amp;lt;lines&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It allows you to change one or more lines in the database table &amp;lt;target&amp;gt;. You can only change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table &amp;lt;target&amp;gt; either statically or dynamically.&lt;/P&gt;&lt;P&gt;Changing Lines Column by Column&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To change certain columns in the database table, use the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE &amp;lt;target&amp;gt; SET &amp;lt;set1&amp;gt; &amp;lt;set 2&amp;gt; ... [WHERE &amp;lt;cond&amp;gt;].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The WHERE clause determines the lines that are changed. If you do not specify a WHERE clause, all lines are changed. The expressions &amp;lt;set i &amp;gt; are three different SET statements that determine the columns to be changed, and how they are to be changed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inserting or Changing Lines &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To insert lines into a database table regardless of whether there is already a line in the table with the same primary key, use the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY &amp;lt;target&amp;gt; &amp;lt;lines&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed.&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&lt;/P&gt;&lt;P&gt;srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Jun 2006 12:29:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-07T12:29:37Z</dc:date>
    <item>
      <title>adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366803#M181315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to add values from a field (CUST_GRP1) of an internal table (TB_CUST_COPA) into a "real" table (/BI0/PCUST_SALES). The CUST_GRP1 should be added in /BI0/PCUST_SALES when there's a match on CUST_SALES, DISTR_CHAN and DIVISION between the two tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should the code look? What's wrong in the code below?&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------" /&gt;&lt;P&gt;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;SELECT CUST_GRP1 FROM /BI0/PCUST_SALES UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;      DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;      DIVISION   = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;      OBJVERS    = 'A'.&lt;/P&gt;&lt;P&gt;/BI0/PCUST_SALES-CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;UPDATE /BI0/PCUST_SALES.&lt;/P&gt;&lt;P&gt;COMMIT WORK.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------" /&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 11:16:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366803#M181315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T11:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366804#M181316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;SELECT * FROM /BI0/PCUST_SALES UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;DIVISION = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;/BI0/PCUST_SALES-CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;UPDATE /BI0/PCUST_SALES.&lt;/P&gt;&lt;P&gt;COMMIT WORK.&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;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wasim Ahmed&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 11:24:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366804#M181316</guid>
      <dc:creator>dani_mn</dc:creator>
      <dc:date>2006-06-07T11:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366805#M181317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at...
SELECT FOR UPDATE...
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No Commit while using &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT FOR UPDATE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; or you can use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at...
UPDATE tablename ......where..
COMMIT WORK 

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt; Thomas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 11:25:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366805#M181317</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T11:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366806#M181318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;use MODIFY instead of update&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY dbtab from itab index sy-tabix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 11:26:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366806#M181318</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T11:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366807#M181319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of it_cust_sales occurs 0.&lt;/P&gt;&lt;P&gt; include structure /BI0/PCUST_SALES.&lt;/P&gt;&lt;P&gt;data: end of it_cust_sales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not TB_CUST_COPA[] is initial.&lt;/P&gt;&lt;P&gt;select * from /BI0/PCUST_SALES into table it_cust_sales&lt;/P&gt;&lt;P&gt;WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;DIVISION = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table it_cust_sales with key CUST_SALES = TB_CUST_COPA-CUST_SALES&lt;/P&gt;&lt;P&gt;DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN DIVISION = TB_CUST_COPA-DIVISION&lt;/P&gt;&lt;P&gt;OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;/BI0/PCUST_SALES-CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;UPDATE /BI0/PCUST_SALES.&lt;/P&gt;&lt;P&gt;COMMIT WORK.&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;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 11:27:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366807#M181319</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T11:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366808#M181320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think you no need to select anything from the database before updating. if you pass all the 3 fields in the where condition of UPDATE, it will take care of everything.&lt;/P&gt;&lt;P&gt;UPDATE &amp;lt;target&amp;gt; SET &amp;lt;set1&amp;gt; &amp;lt;set 2&amp;gt; ... [WHERE &amp;lt;cond&amp;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;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;  UPDATE /BI0/PCUST_SALES&lt;/P&gt;&lt;P&gt;           SET CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;   WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;         DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;         DIVISION = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;         OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This logic will do that.&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>Wed, 07 Jun 2006 11:29:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366808#M181320</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T11:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366809#M181321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all your code-examples!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I followed the code from Wasim, but I get a short dump directly after the COMMIT WORK. Why is this and how can I solve it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I only added ENDSELECT. in the code from Wasim... Was this ok?&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;SELECT * FROM /BI0/PCUST_SALES UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;DIVISION = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;/BI0/PCUST_SALES-CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;UPDATE /BI0/PCUST_SALES.&lt;/P&gt;&lt;P&gt;COMMIT WORK.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 12:09:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366809#M181321</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T12:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366810#M181322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Fredrik ,&lt;/P&gt;&lt;P&gt;  why to fetch the database 2 times for 1 particular task ? as UPDATE itself will take care of updating the values of a particular fields in the database table based on the condition given in WHERE clause. &lt;/P&gt;&lt;P&gt;the current logic may some times takes more processing time, if the no of records is more, as it should do 2 times database hits (1 for fetching &amp;amp; 1 for updating)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 12:15:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366810#M181322</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T12:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366811#M181323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I chose to use the code from Srikanth. This worked fine and updated the target table. Should the "update" be changed into "modify"? Why?&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;LOOP AT TB_CUST_COPA.&lt;/P&gt;&lt;P&gt;UPDATE /BI0/PCUST_SALES&lt;/P&gt;&lt;P&gt;SET CUST_GRP1 = TB_CUST_COPA-CUST_GRP1.&lt;/P&gt;&lt;P&gt;WHERE CUST_SALES = TB_CUST_COPA-CUST_SALES AND&lt;/P&gt;&lt;P&gt;DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND&lt;/P&gt;&lt;P&gt;DIVISION = TB_CUST_COPA-DIVISION AND&lt;/P&gt;&lt;P&gt;OBJVERS = 'A'.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 12:23:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366811#M181323</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T12:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366812#M181324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt; we should NOT use MODIFY in your case, as  MODIFY will be used for Inserting/changing records.&lt;/P&gt;&lt;P&gt;if the record does not exists, it will insert the record.&lt;/P&gt;&lt;P&gt;if the record exists, it will change the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but UPDATE will do only works if the matching record exists in the database, it wont create at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the description of both(copied from sap library)&lt;/P&gt;&lt;P&gt;Changing Lines &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Open SQL statement for changing data in a database table is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE &amp;lt;target&amp;gt; &amp;lt;lines&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It allows you to change one or more lines in the database table &amp;lt;target&amp;gt;. You can only change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table &amp;lt;target&amp;gt; either statically or dynamically.&lt;/P&gt;&lt;P&gt;Changing Lines Column by Column&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To change certain columns in the database table, use the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE &amp;lt;target&amp;gt; SET &amp;lt;set1&amp;gt; &amp;lt;set 2&amp;gt; ... [WHERE &amp;lt;cond&amp;gt;].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The WHERE clause determines the lines that are changed. If you do not specify a WHERE clause, all lines are changed. The expressions &amp;lt;set i &amp;gt; are three different SET statements that determine the columns to be changed, and how they are to be changed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inserting or Changing Lines &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To insert lines into a database table regardless of whether there is already a line in the table with the same primary key, use the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY &amp;lt;target&amp;gt; &amp;lt;lines&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed.&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&lt;/P&gt;&lt;P&gt;srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 12:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366812#M181324</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T12:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: adding field values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366813#M181325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the information and support!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2006 12:37:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-field-values-from-internal-table/m-p/1366813#M181325</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-07T12:37:03Z</dc:date>
    </item>
  </channel>
</rss>

