<?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: Performance issue and functional question regarding updates on tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605266#M868345</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have mentioned what version we are on - we are running ECC 6.0 - I found some updated documentation as follows in case anyone following this is on a more recent version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483" target="test_blank"&gt;https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483&lt;/A&gt; - Using ABAP - one thing though - the "update" process is nowhere nearly defined as in the prior document.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Mar 2008 00:25:21 GMT</pubDate>
    <dc:creator>bruce_hartley</dc:creator>
    <dc:date>2008-03-28T00:25:21Z</dc:date>
    <item>
      <title>Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605261#M868340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A person at my site wrote some code to update a custom field on the MARC table that was being copied from the MARA table.  Here is what I would have expected to see as the code.  Assume that both sets of code have a parameter called p_werks which is the plant in question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : commit_count type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select matnr zfield from mara into (wa_marc-matnr, wa_marc-zfield).&lt;/P&gt;&lt;P&gt;  update marc set zfield = wa_marc-zfield&lt;/P&gt;&lt;P&gt;     where werks = p_werks and matnr = wa_matnr.&lt;/P&gt;&lt;P&gt;  commit work and wait.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have committed every 200 rows instead of every one row, but here's the actual code and my question isn't around the commits but something else.  In this case an internal table was built with two elements - MATNR and WERKS - could have done that above too, but that's not my question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            DO.&lt;/P&gt;&lt;P&gt;              " Lock the record that needs to be update with material creation date&lt;/P&gt;&lt;P&gt;              CALL FUNCTION 'ENQUEUE_EMMARCS'&lt;/P&gt;&lt;P&gt;                EXPORTING&lt;/P&gt;&lt;P&gt;                  mode_marc      = 'S'&lt;/P&gt;&lt;P&gt;                  mandt          = sy-mandt&lt;/P&gt;&lt;P&gt;                  matnr          = wa_marc-matnr&lt;/P&gt;&lt;P&gt;                  werks          = wa_marc-werks&lt;/P&gt;&lt;P&gt;                EXCEPTIONS&lt;/P&gt;&lt;P&gt;                  foreign_lock   = 1&lt;/P&gt;&lt;P&gt;                  system_failure = 2&lt;/P&gt;&lt;P&gt;                  OTHERS         = 3.&lt;/P&gt;&lt;P&gt;              IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;                " Wait, if the records not able to perform as lock&lt;/P&gt;&lt;P&gt;                CALL FUNCTION 'RZL_SLEEP'.&lt;/P&gt;&lt;P&gt;              ELSE.&lt;/P&gt;&lt;P&gt;                EXIT.&lt;/P&gt;&lt;P&gt;              ENDIF.&lt;/P&gt;&lt;P&gt;            ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            " Update the record in the table MARC with material creation date&lt;/P&gt;&lt;P&gt;            UPDATE marc SET zzdate = wa_mara-zzdate&lt;/P&gt;&lt;P&gt;                       WHERE matnr = wa_mara-matnr AND&lt;/P&gt;&lt;P&gt;                             werks = wa_marc-werks.    " IN s_werks.&lt;/P&gt;&lt;P&gt;            IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;              " Save record in the database table MARC&lt;/P&gt;&lt;P&gt;              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'&lt;/P&gt;&lt;P&gt;                EXPORTING&lt;/P&gt;&lt;P&gt;                  wait   = 'X'&lt;/P&gt;&lt;P&gt;                IMPORTING&lt;/P&gt;&lt;P&gt;                  return = wa_return.&lt;/P&gt;&lt;P&gt;              wa_log-matnr   = wa_marc-matnr.&lt;/P&gt;&lt;P&gt;              wa_log-werks   = wa_marc-werks.&lt;/P&gt;&lt;P&gt;              wa_log-type    = 'S'.&lt;/P&gt;&lt;P&gt;              " text-010 - 'Material creation date has updated'.&lt;/P&gt;&lt;P&gt;              wa_log-message = text-010.&lt;/P&gt;&lt;P&gt;              wa_log-zzdate  = wa_mara-zzdate.&lt;/P&gt;&lt;P&gt;              APPEND wa_log TO tb_log.&lt;/P&gt;&lt;P&gt;              CLEAR: wa_return,wa_log.&lt;/P&gt;&lt;P&gt;            ELSE.&lt;/P&gt;&lt;P&gt;              " Roll back the record(un save), if there is any issue occurs&lt;/P&gt;&lt;P&gt;              CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'&lt;/P&gt;&lt;P&gt;                IMPORTING&lt;/P&gt;&lt;P&gt;                  return = wa_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              wa_log-matnr   = wa_marc-matnr.&lt;/P&gt;&lt;P&gt;              wa_log-werks   = wa_marc-werks.&lt;/P&gt;&lt;P&gt;              wa_log-type    = 'E'.&lt;/P&gt;&lt;P&gt;              " 'Material creation date does not updated'.&lt;/P&gt;&lt;P&gt;              wa_log-message = text-011.&lt;/P&gt;&lt;P&gt;              wa_log-zzdate  = wa_mara-zzdate..&lt;/P&gt;&lt;P&gt;              APPEND wa_log TO tb_log.&lt;/P&gt;&lt;P&gt;              CLEAR: wa_return, wa_log.&lt;/P&gt;&lt;P&gt;            ENDIF.&lt;/P&gt;&lt;P&gt;            " Unlock the record from data base&lt;/P&gt;&lt;P&gt;            CALL FUNCTION 'DEQUEUE_EMMARCS'&lt;/P&gt;&lt;P&gt;              EXPORTING&lt;/P&gt;&lt;P&gt;                mode_marc = 'S'&lt;/P&gt;&lt;P&gt;                mandt     = sy-mandt&lt;/P&gt;&lt;P&gt;                matnr     = wa_marc-matnr&lt;/P&gt;&lt;P&gt;                werks     = wa_marc-werks.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the question - why did this person enqueue and dequeue explicit locks like this ?  They claimed it was to prevent issues - what issues ???  Is there something special about updating tables that we don't know about ?  We've actually seen it where the system runs out of these ENQUEUE locks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before you all go off the deep end and ask why not just do the update, keep in mind that you don't want to update a million + rows and then do a commit either - that locks up the entire table!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 20:20:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605261#M868340</guid>
      <dc:creator>bruce_hartley</dc:creator>
      <dc:date>2008-03-27T20:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605262#M868341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The &lt;STRONG&gt;ENQUEUE&lt;/STRONG&gt; lock insure that another program called by another user will not update the data at the same time, so preventing database coherence to be lost. In fact, another user on a SAP correct transaction, has read the record and locked it, so when it will be updated your modifications will be lost, also you could override modifications made by another user in another luw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot use a &lt;STRONG&gt;COMMIT WORK&lt;/STRONG&gt; in a &lt;STRONG&gt;SELECT - ENDSELECT&lt;/STRONG&gt;, because COMMIT WORK will close each and every opened database cursor, so your first idea would dump after the first update. (so the internal table is mandatory) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go through some documentation like [Updates in the R/3 System (BC-CST-UP)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCSTUP/BCCSTUP_PT.pdf]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 21:59:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605262#M868341</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2008-03-27T21:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605263#M868342</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;Why are you using the direct DB update. Use BAPI or BDC so you may not be required to worry of all ENQUE,DEQUE stuff. SAP will take care of these.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also Direct DB update of standard table shoul be the last solution when you don't have any other option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 22:30:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605263#M868342</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T22:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605264#M868343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I presume (hope) that you are not in productive stage, but preparing the start of production ?&lt;/P&gt;&lt;P&gt;Else Atish is right, use the BAPI_MATERIAL_SAVEDATA passing your customer field in the EXTENSION parameter of the BAPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may look at OSS [Note 211815 - Not all flds onl.maint.in StandardMaterial.SaveData|https://service.sap.com/sap/support/notes/211815]  to add your customer fields to this BAPI interface.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 22:41:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605264#M868343</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2008-03-27T22:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605265#M868344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the link on the updates - I'm going to read that and then get back to this and possibly close this out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Bruce Hartley on Mar 27, 2008 7:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 23:37:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605265#M868344</guid>
      <dc:creator>bruce_hartley</dc:creator>
      <dc:date>2008-03-27T23:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue and functional question regarding updates on tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605266#M868345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have mentioned what version we are on - we are running ECC 6.0 - I found some updated documentation as follows in case anyone following this is on a more recent version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483" target="test_blank"&gt;https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483&lt;/A&gt; - Using ABAP - one thing though - the "update" process is nowhere nearly defined as in the prior document.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 00:25:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-and-functional-question-regarding-updates-on-tables/m-p/3605266#M868345</guid>
      <dc:creator>bruce_hartley</dc:creator>
      <dc:date>2008-03-28T00:25:21Z</dc:date>
    </item>
  </channel>
</rss>

