<?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: How to update key field? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450719#M1999475</link>
    <description>&lt;P&gt;I understood it as "the table is not used in a search help", but I understand you tested it and this is not the case.&lt;/P&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;Mateusz</description>
    <pubDate>Thu, 15 Apr 2021 15:34:52 GMT</pubDate>
    <dc:creator>MateuszAdamus</dc:creator>
    <dc:date>2021-04-15T15:34:52Z</dc:date>
    <item>
      <title>How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450710#M1999466</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;
  &lt;P&gt;I have this problem: &lt;/P&gt;
  &lt;P&gt;In the table z_zxx I have key1, key2, key3, key4. &lt;/P&gt;
  &lt;P&gt;Key2 is a char field of length 12 but up to this point values of length 11 have been saved. &lt;/P&gt;
  &lt;P&gt;For example, values such as 123456789xx are saved instead of 0123456789xx.&lt;/P&gt;
  &lt;P&gt;I want to change key2 from 123456789xx to 0123456789xx&lt;/P&gt;
  &lt;P&gt;Modify z_zxx from wa_zxx creates a new entry with key 0123456789xx instead of modifying the existing one.&lt;/P&gt;
  &lt;P&gt;UPDATE z_zxx&lt;/P&gt;
  &lt;P&gt; SET key2 = wa_zxx-key2&lt;/P&gt;
  &lt;P&gt; WHERE key1 = wa_zxx-key1 AND &lt;/P&gt;
  &lt;P&gt; key2 = key2_old AND &lt;/P&gt;
  &lt;P&gt; key3 = wa_zxx-key3 AND &lt;/P&gt;
  &lt;P&gt; key4 = wa_zxx-key4.&lt;/P&gt;
  &lt;P&gt;How to solve this problem?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 09:35:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450710#M1999466</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-15T09:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450711#M1999467</link>
      <description>&lt;P&gt;I forgot to mention that Update statement does not work&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 09:36:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450711#M1999467</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-15T09:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450712#M1999468</link>
      <description>&lt;P&gt;Hello  &lt;SPAN class="mention-scrubbed"&gt;tearm&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;You cannot. You need to create new entries with the new key values and delete the old records.&lt;/P&gt;&lt;P&gt;Edit: Actually it is possible, but with some constraints (thanks  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; for pointing that out):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The content of primary key fields can only be changed if the respective database table is not linked with a search help and if pool and cluster tables are not accessed. If these changes would create a row which would produce duplicate entries in the primary key or a unique secondary index of the database table, no rows are changed and sy-subrc is set to 4.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapupdate_source.htm"&gt;https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapupdate_source.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;BR /&gt;Mateusz&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 09:39:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450712#M1999468</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2021-04-15T09:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450713#M1999469</link>
      <description>&lt;P&gt;Update should work on key fields as well as long as it creates no duplication.&lt;/P&gt;&lt;P&gt;Did you try to run the UPDATE statement you pasted?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 10:35:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450713#M1999469</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-15T10:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450714#M1999470</link>
      <description>&lt;P&gt;Yes, it returns sy-subrc = 4&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 10:46:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450714#M1999470</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-15T10:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450715#M1999471</link>
      <description>&lt;P&gt;Please, for future questions, select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for us to analyze it. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 12:45:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450715#M1999471</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-04-15T12:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450716#M1999472</link>
      <description>&lt;P&gt;SQL permits to update the values of key columns, it's only preventing from having duplicate values of unique keys or other database constraints.&lt;/P&gt;&lt;P&gt;(but ABAP prevents from changing key fields of internal tables)&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 12:47:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450716#M1999472</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-04-15T12:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450717#M1999473</link>
      <description>&lt;P&gt;Hi Sandra,&lt;/P&gt;&lt;P&gt;You're right. However, there seems to be an additional condition for this.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The content of primary key fields can only be changed if the respective database table is not linked with a search help and if pool and cluster tables are not accessed. If these changes would create a row which would produce duplicate entries in the primary key or a unique secondary index of the database table, no rows are changed and sy-subrc is set to 4.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapupdate_source.htm"&gt;https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapupdate_source.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I have update my answer accordingly. &lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Mateusz&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 13:04:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450717#M1999473</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2021-04-15T13:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450718#M1999474</link>
      <description>&lt;P&gt;Thanks for the ABAP note.&lt;/P&gt;&lt;P&gt;I don't know what is the exact meaning about the search help, I did a quick ugly test with T002 which is linked to H_T002 at table level:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;UPDATE t002 SET spras = '}' WHERE spras = 'D'.
WRITE sy-subrc.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In a Sybase 7.52 Developer Edition, the update was successful.&lt;/P&gt;&lt;P&gt;In a S/4HANA 7.52 system, there is a HANA database trigger which fails after ABAP:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Category               ABAP programming error
Runtime Errors         DBSQL_SQL_ERROR
Except.                CX_SY_OPEN_SQL_DB
ABAP Program           ZTEST
Application Component  Not assigned
Date and Time          15.04.2021 21:11:06

 Short Text
     SQL error "SQL code: 465" occurred while accessing table "T002".

 What happened?
     Database error text: "SQL message: Cannot execute trigger, was invalidated by
      object change: failure in revalidating check for update trigger
      (SAPXXX.T002_U_HADP_TRIG)"
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also did a test with T002T which has a search help at column level, but it was again successful.&lt;/P&gt;&lt;P&gt;Any idea what "&lt;EM&gt;can only be changed if the respective database table is not linked with a search help&lt;/EM&gt;" means in the UPDATE context? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 15:27:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450718#M1999474</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-04-15T15:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450719#M1999475</link>
      <description>&lt;P&gt;I understood it as "the table is not used in a search help", but I understand you tested it and this is not the case.&lt;/P&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;Mateusz</description>
      <pubDate>Thu, 15 Apr 2021 15:34:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450719#M1999475</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2021-04-15T15:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to update key field?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450720#M1999476</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Eventually i created new entries and deleted the old ones.&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 05:41:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-update-key-field/m-p/12450720#M1999476</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-04-16T05:41:24Z</dc:date>
    </item>
  </channel>
</rss>

