<?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: necessity of using lock objects in programming in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767480#M2022841</link>
    <description>&lt;P&gt;Hi Zhumabek,&lt;/P&gt;&lt;P&gt;It is used all the time, but it really depends on the situation. Here is an example.&lt;/P&gt;&lt;P&gt;Let's say you have a program that displays the content of a table in a grid, and allows to change the content, and save it in the database. Now Bob calls this program and displays the content of the first record. A minute later, Jane calls the same program and also displays the content of the first record. Then Bob changes the value of field A on that record and saves it in the database. In SAP this change will not automatically be shown on Jane's screen. It would require the program to reload the data from the database. Jane, not knowing that Bob made a change in field A on the first record, also changes the same field on the same record, puts in a different value and save. Now Bob has lost its changes and will not be notified of the situation.&lt;/P&gt;&lt;P&gt;To prevent this sort of situation, SAP provides Lock Objects. The creation of a Lock Object generates two distinct Function Modules: the Enqueue Function and the Dequeue Function. The first locks an entry, the second unlocks it. If you try to call the first one when it has already been called by someone else (or even by yourself on another session), the Function will return an error. You can see current lock entries by calling transaction SM12.&lt;/P&gt;&lt;P&gt;Now, two things to know about Lock Objects:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Lock Objects in SAP don't actually "lock" the entries. They simply create a lock entry in a table. It is your responsibility as a programmer to use this information and determine what to do when you detect that something has already been locked. Nothing will prevent you to make a database change if you don't check if a lock entry exist or not.&lt;/LI&gt;&lt;LI&gt;Lock entries are Key specific. This means that if you call the Enqueue Function without specifying a key (to lock the entire table), and another program calls the same Enqueue Function with a specific key, it will not detect that there is already a lock entry since the lock entry without a key and the lock entry with a key are two different lock entries that don't block each other.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;Patrice Poirier&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 16:21:10 GMT</pubDate>
    <dc:creator>Patrice</dc:creator>
    <dc:date>2023-09-12T16:21:10Z</dc:date>
    <item>
      <title>necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767474#M2022835</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
  &lt;P&gt;How nessesary is using a lock objects in programming with updating/inserting/appending data to transparent tables? And what would happen if not to use it in such cases?&lt;/P&gt;
  &lt;P&gt;And where using it is nessesary?&lt;/P&gt;
  &lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 13:01:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767474#M2022835</guid>
      <dc:creator>jumabek2707</dc:creator>
      <dc:date>2023-09-11T13:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767475#M2022836</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="mention-scrubbed"&gt;jumabek2707&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Lock objects are a must in concurrent programming! &lt;/P&gt;&lt;P&gt;Typically a business object is implemented with several transparent tables e.g. sales order - tables VBAK, VBAP, etc. If you are going to create/update a business object, you need to lock entries in all the relevant tables to make sure no one is going to update them in parallel. That is what enqueue / lock objects do for you.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Dominik Tylczynski&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 13:19:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767475#M2022836</guid>
      <dc:creator>Dominik_Tylczynski</dc:creator>
      <dc:date>2023-09-11T13:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767476#M2022837</link>
      <description>&lt;P&gt;That's not parallel programming. That's concurrent use of an application.&lt;/P&gt;&lt;P&gt;Otherwise, spot on. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 13:23:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767476#M2022837</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-09-11T13:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767477#M2022838</link>
      <description>&lt;P&gt;When you read data, it's not necessary.&lt;/P&gt;&lt;P&gt;But when you add/update/delete data and another process could manipulate the table at the same time, then it's recommended to lock the table beforehand.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 13:37:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767477#M2022838</guid>
      <dc:creator>thkolz</dc:creator>
      <dc:date>2023-09-11T13:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767478#M2022839</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;matthew.billingham&lt;/SPAN&gt; Thank you! - updated "parallel" to "concurrent"&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 13:39:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767478#M2022839</guid>
      <dc:creator>Dominik_Tylczynski</dc:creator>
      <dc:date>2023-09-11T13:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767479#M2022840</link>
      <description>&lt;P&gt;You can find many answers in the SAP forum:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;need of lock objects site:sap.com&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2023 18:19:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767479#M2022840</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-09-11T18:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: necessity of using lock objects in programming</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767480#M2022841</link>
      <description>&lt;P&gt;Hi Zhumabek,&lt;/P&gt;&lt;P&gt;It is used all the time, but it really depends on the situation. Here is an example.&lt;/P&gt;&lt;P&gt;Let's say you have a program that displays the content of a table in a grid, and allows to change the content, and save it in the database. Now Bob calls this program and displays the content of the first record. A minute later, Jane calls the same program and also displays the content of the first record. Then Bob changes the value of field A on that record and saves it in the database. In SAP this change will not automatically be shown on Jane's screen. It would require the program to reload the data from the database. Jane, not knowing that Bob made a change in field A on the first record, also changes the same field on the same record, puts in a different value and save. Now Bob has lost its changes and will not be notified of the situation.&lt;/P&gt;&lt;P&gt;To prevent this sort of situation, SAP provides Lock Objects. The creation of a Lock Object generates two distinct Function Modules: the Enqueue Function and the Dequeue Function. The first locks an entry, the second unlocks it. If you try to call the first one when it has already been called by someone else (or even by yourself on another session), the Function will return an error. You can see current lock entries by calling transaction SM12.&lt;/P&gt;&lt;P&gt;Now, two things to know about Lock Objects:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Lock Objects in SAP don't actually "lock" the entries. They simply create a lock entry in a table. It is your responsibility as a programmer to use this information and determine what to do when you detect that something has already been locked. Nothing will prevent you to make a database change if you don't check if a lock entry exist or not.&lt;/LI&gt;&lt;LI&gt;Lock entries are Key specific. This means that if you call the Enqueue Function without specifying a key (to lock the entire table), and another program calls the same Enqueue Function with a specific key, it will not detect that there is already a lock entry since the lock entry without a key and the lock entry with a key are two different lock entries that don't block each other.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;Patrice Poirier&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 16:21:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/necessity-of-using-lock-objects-in-programming/m-p/12767480#M2022841</guid>
      <dc:creator>Patrice</dc:creator>
      <dc:date>2023-09-12T16:21:10Z</dc:date>
    </item>
  </channel>
</rss>

