<?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: Insert or Update - Update Fails? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981603#M1340930</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;That change did not work either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the error analysis:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You attempted to change, delete or create a line in the&lt;/P&gt;&lt;P&gt;internal table "\PROGRAM=ZSD_SLSORD_HIST_2COPA\DATA=IT_IPDATA", but no v&lt;/P&gt;&lt;P&gt; cursor exists&lt;/P&gt;&lt;P&gt;for the table.&lt;/P&gt;&lt;P&gt;Possible reasons:&lt;/P&gt;&lt;P&gt;1. The relevent ABAP/4 statement does not include the addition&lt;/P&gt;&lt;P&gt;   "...INDEX...", although the statement is not&lt;/P&gt;&lt;P&gt;   inside a "LOOP...ENDLOOP" loop processing this table.&lt;/P&gt;&lt;P&gt;2. The relevent ABAP/4 statement was called from within a&lt;/P&gt;&lt;P&gt;   "LOOP...ENDLOOP" loop after a DELETE&lt;/P&gt;&lt;P&gt; "\PROGRAM=ZSD_SLSORD_HIST_2COPA\DATA=IT_IPDATA".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jul 2009 16:26:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-30T16:26:05Z</dc:date>
    <item>
      <title>Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981599#M1340926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frorums&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I execute this code, the insert works into my table however, the update does not, it causes the program to abort.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM UPDATE_ZPRDCOPATOT .
  DATA: LV_SALES LIKE ZPRDCOPATOT-ZGROSSALES,
        LV_COST  LIKE ZPRDCOPATOT-ZINTPRICE.


  TOT_REC-ZPERIOD = GV_PERIOD.
  TOT_REC-ZDISTCHAN = GV_CURR_CHANNEL.
  TOT_REC-ZGROSSALES = GV_TOTAL_SALES.
  TOT_REC-ZINTPRICE = GV_TOTAL_COST.

  SELECT * FROM
    ZPRDCOPATOT WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
  ENDSELECT.

  IF sy-subrc = 4.
    INSERT INTO ZPRDCOPATOT VALUES TOT_REC.
  ELSEIF SY-SUBRC EQ 0.
    TOT_REC-ZGROSSALES = TOT_REC-ZGROSSALES + ZPRDCOPATOT-ZGROSSALES.
    TOT_REC-ZINTPRICE = TOT_REC-ZINTPRICE + ZPRDCOPATOT-ZINTPRICE.
    MODIFY TOT_REC.
    UPDATE ZPRDCOPATOT SET
    ZGROSSALES = TOT_REC-ZGROSSALES
    ZINTPRICE  = TOT_REC-ZINTPRICE
    WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.

  ENDIF.
  CLEAR: GV_TOTAL_SALES, GV_TOTAL_COST.

ENDFORM.                    " UPDATE_ZPRDCOPATOT
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: keith warnock on Jul 30, 2009 6:06 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981599#M1340926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981600#M1340927</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; When I execute this code, the insert works into my table however, the update does not, it causes the program to abort.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 FORM UPDATE_ZPRDCOPATOT .
   DATA: LV_SALES LIKE ZPRDCOPATOT-ZGROSSALES,
         LV_COST  LIKE ZPRDCOPATOT-ZINTPRICE.
 
 
   TOT_REC-ZPERIOD = GV_PERIOD.
   TOT_REC-ZDISTCHAN = GV_CURR_CHANNEL.
   TOT_REC-ZGROSSALES = GV_TOTAL_SALES.
   TOT_REC-ZINTPRICE = GV_TOTAL_COST.
 
   SELECT * FROM
     ZPRDCOPATOT WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
   ENDSELECT.
 
   IF sy-subrc = 4.
     INSERT INTO ZPRDCOPATOT VALUES TOT_REC.
   ELSEIF SY-SUBRC EQ 0.
     TOT_REC-ZGROSSALES = TOT_REC-ZGROSSALES + ZPRDCOPATOT-ZGROSSALES.
     TOT_REC-ZINTPRICE = TOT_REC-ZINTPRICE + ZPRDCOPATOT-ZINTPRICE.
     MODIFY TOT_REC.
     UPDATE ZPRDCOPATOT SET
     ZGROSSALES = TOT_REC-ZGROSSALES
     ZINTPRICE  = TOT_REC-ZINTPRICE
     "WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.                                    "comment this
      WHERE ZPERIOD = ZPRDCOPATOT- ZPERIOD   AND ZDISTCHAN = ZPRDCOPATOT-ZDISTCHAN.  "Write this
 
   ENDIF.
   CLEAR: GV_TOTAL_SALES, GV_TOTAL_COST.
 
 ENDFORM.                    " UPDATE_ZPRDCOPATOT
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;P&gt;Prabhudas &lt;/P&gt;&lt;P&gt;&amp;gt; Edited by: keith warnock on Jul 30, 2009 6:06 PM&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:11:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981600#M1340927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981601#M1340928</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 made the code change but still got the same error... Here it is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;short text:&lt;/P&gt;&lt;P&gt; Error in an ABAP/4 statement when processing an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dump, shows the program failing right at the update statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:16:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981601#M1340928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981602#M1340929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    In your code after SELECT statement try with sy-dbcnt value. See below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM
    ZPRDCOPATOT WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
  ENDSELECT.
 
  IF sy-dbcnt = 0.         " ----&amp;gt; Do this change
    INSERT INTO ZPRDCOPATOT VALUES TOT_REC.
  ELSEIF sy-dbcnt EQ 1.        " ----&amp;gt; Do this change
    TOT_REC-ZGROSSALES = TOT_REC-ZGROSSALES + ZPRDCOPATOT-ZGROSSALES.
    TOT_REC-ZINTPRICE = TOT_REC-ZINTPRICE + ZPRDCOPATOT-ZINTPRICE.
    MODIFY TOT_REC.
    UPDATE ZPRDCOPATOT SET
    ZGROSSALES = TOT_REC-ZGROSSALES
    ZINTPRICE  = TOT_REC-ZINTPRICE
    WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
 
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:20:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981602#M1340929</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-07-30T16:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981603#M1340930</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;That change did not work either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the error analysis:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You attempted to change, delete or create a line in the&lt;/P&gt;&lt;P&gt;internal table "\PROGRAM=ZSD_SLSORD_HIST_2COPA\DATA=IT_IPDATA", but no v&lt;/P&gt;&lt;P&gt; cursor exists&lt;/P&gt;&lt;P&gt;for the table.&lt;/P&gt;&lt;P&gt;Possible reasons:&lt;/P&gt;&lt;P&gt;1. The relevent ABAP/4 statement does not include the addition&lt;/P&gt;&lt;P&gt;   "...INDEX...", although the statement is not&lt;/P&gt;&lt;P&gt;   inside a "LOOP...ENDLOOP" loop processing this table.&lt;/P&gt;&lt;P&gt;2. The relevent ABAP/4 statement was called from within a&lt;/P&gt;&lt;P&gt;   "LOOP...ENDLOOP" loop after a DELETE&lt;/P&gt;&lt;P&gt; "\PROGRAM=ZSD_SLSORD_HIST_2COPA\DATA=IT_IPDATA".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:26:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981603#M1340930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981604#M1340931</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;Update with set expression will works fine,  if the data records are exists already it will updates.&lt;/P&gt;&lt;P&gt;in your where condition you are checking two fields that condition is statisfying or not please check it once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example below code I tried working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: mara.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: it_mara type standard table of mara  with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_mara-matnr = '100-100'.&lt;/P&gt;&lt;P&gt;it_mara-matkl = '001'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;update mara  set&lt;/P&gt;&lt;P&gt;matkl = it_mara-matkl&lt;/P&gt;&lt;P&gt;where matnr = it_mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&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;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:30:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981604#M1340931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981605#M1340932</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;PRE&gt;&lt;CODE&gt;
    MODIFY TOT_REC.  "Comment this and check 
     UPDATE ZPRDCOPATOT SET
     ZGROSSALES = TOT_REC-ZGROSSALES
      WHERE ZPERIOD = ZPRDCOPATOT-ZPERIOD   AND ZDISTCHAN = ZPRDCOPATOT-ZDISTCHAN.  
   &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:34:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981605#M1340932</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981606#M1340933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THE MODIFY TOT_REC was the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks ALL&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:35:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981606#M1340933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T16:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Insert or Update - Update Fails?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981607#M1340934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    In your code ZGROSSALES, ZINTPRICE after ENDSELECT does this fields have the values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Just try keeping the ENDSELECT statement after ENDIF. as below.

SELECT * FROM
    ZPRDCOPATOT WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
  
 
  IF sy-dbcnt = 0.         
    INSERT INTO ZPRDCOPATOT VALUES TOT_REC.
  ELSEIF sy-dbcnt EQ 1.       
    TOT_REC-ZGROSSALES = TOT_REC-ZGROSSALES + ZPRDCOPATOT-ZGROSSALES.
    TOT_REC-ZINTPRICE = TOT_REC-ZINTPRICE + ZPRDCOPATOT-ZINTPRICE.
    MODIFY TOT_REC.
    UPDATE ZPRDCOPATOT SET
    ZGROSSALES = TOT_REC-ZGROSSALES
    ZINTPRICE  = TOT_REC-ZINTPRICE
    WHERE ZPERIOD = GV_PERIOD AND ZDISTCHAN = GV_CURR_CHANNEL.
 
  ENDIF.

ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 16:35:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-or-update-update-fails/m-p/5981607#M1340934</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-07-30T16:35:55Z</dc:date>
    </item>
  </channel>
</rss>

