{"id":322,"date":"2013-04-04T19:25:54","date_gmt":"2013-04-04T18:25:54","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=322"},"modified":"2013-04-17T19:36:33","modified_gmt":"2013-04-17T18:36:33","slug":"row-level-locking-of-database-table","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=322","title":{"rendered":"Row level locking of database table"},"content":{"rendered":"<p><img decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"alignleft  wp-image-358\" alt=\"SAP\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" width=\"50\" \/>The default behavior is if a person opens table maintenance generator and tries to maintain the table, the table is locked and no one else can maintain the same table at the same time.<\/p>\n<p>This is because there is a &#8220;table-level lock&#8221; by default in SAP. This means only one user can maintain any table at a time through SM30 or any transaction that calls table maintenance generator. In the tutorial below you will find out how to replace table level lock with row level lock.<br \/>\nBy row-level lock you ensure any number of users can modify the table at same time, but any particular row can be modified by only one user at a time (the first one who accessed the row for maintenance). We will create a transaction for this purpose. This transaction will call our custom report where at first the table lock is deleted and subsequently the table maintenance generator will be called.<!--more-->.<\/p>\n<h1>In our example we will create<\/h1>\n<ul>\n<li><span style=\"line-height: 15px;\">Custom report ZREP_ROWLOCK<\/span><\/li>\n<li>Transaction to call the custom report ZRLOCK<\/li>\n<li>Custom table with maintenance generator ZROWLOCK<\/li>\n<\/ul>\n<p>Transaction ZRLOCK will call report ZREP_ROWLOCK where we delete table-level lock on ZROWLOCK and then it calls the table maintenance where only selected rows will be locked. This will ensure that multiple users can access the table at the same time. But rows locked by one user can not be edited by anyone else until this user leaves the table maintenance and releases the row locks.<\/p>\n<h1>Create table ZROWLOCK<\/h1>\n<p>Go to SE11 and create new table ZROWLOCK with at least the following fields: MANDT, MATNR, WERKS and activate the table.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock01.png\"><img decoding=\"async\" data-attachment-id=\"340\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=340\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock01.png\" data-orig-size=\"\" data-comments-opened=\"1\" data-image-meta=\"[]\" data-image-title=\"Table creation\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock01.png\" class=\"size-medium wp-image-340 alignnone\" alt=\"Table creation\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock01.png\" \/><\/a><\/p>\n<h1>Call table maintenance generator for the table.<\/h1>\n<p>In the top menu go to Utilities &#8211; Table Maintenance Generator and create new function group for this table. Generate code for one step\/single screen.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"339\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=339\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02.png\" data-orig-size=\"597,489\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Table maintenance generator\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02.png\" class=\"size-full wp-image-339 alignnone\" alt=\"Table maintenance generator\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02.png\" width=\"597\" height=\"489\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02.png 597w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02-300x245.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock02-366x300.png 366w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/a><\/p>\n<h1>Create lock object<\/h1>\n<p>Go to SE11 and create new lock with name as EZROWLOCK<br \/>\nEnter the name of our custom table (ZROWLOCK) and select lock mode (Write)<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"338\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=338\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03.png\" data-orig-size=\"607,396\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Table lock creation 1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03.png\" class=\"size-full wp-image-338 alignnone\" alt=\"Table lock creation 1\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03.png\" width=\"607\" height=\"396\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03.png 607w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03-300x195.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock03-459x300.png 459w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/a><\/p>\n<p>Now select all the key fields of table ZROWLOCK<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"337\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=337\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04.png\" data-orig-size=\"615,297\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Table lock creation 2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04.png\" class=\"size-full wp-image-337 alignleft\" alt=\"Table lock creation 2\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04.png\" width=\"615\" height=\"297\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04.png 615w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04-300x144.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock04-500x241.png 500w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/a><\/p>\n<p>Now save and activate the Lock object. SAP automaticall creates two function modules corresponding to lock object for enqueue and dequeue action on table ZROWLOCK<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"336\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=336\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05.png\" data-orig-size=\"463,34\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Generated lock\/unlock function modules\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05.png\" class=\"size-full wp-image-336 alignnone\" alt=\"Generated lock\/unlock function modules\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05.png\" width=\"463\" height=\"34\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05.png 463w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock05-300x22.png 300w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<h1>Create report and transaction<\/h1>\n<p>Go to SE38 and create new report called ZREP_ROWLOCK.<br \/>\nThis code will delete the table-level lock on ZROWLOCK table and call its table maintenance.<\/p>\n<pre lang=\"abap\">*&amp;---------------------------------------------------------------------*\r\n *&amp;\u00a0Report\u00a0\u00a0ZREP_ROWLOCK\r\n *&amp;\r\n *&amp;---------------------------------------------------------------------\r\n *&amp;\u00a0Author \u00a0 \u00a0 \u00a0:\u00a0Miroslav Oprsteny\r\n *&amp;\u00a0Date \u00a0 \u00a0 \u00a0 \u00a0:\u00a02013\/04\/04\r\n *&amp;\u00a0Description\u00a0: Database table row-level lock demo\r\n *&amp;---------------------------------------------------------------------*\r\n REPORT\u00a0\u00a0zrep_rowlock.\r\n* Selection\u00a0screen for\u00a0view\u00a0maintenance\r\n DATA:\u00a0BEGIN\u00a0OF\u00a0selekttab\u00a0OCCURS\u00a01.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n         INCLUDE\u00a0STRUCTURE\u00a0vimsellist.\r\n DATA:\u00a0END\u00a0OF\u00a0selekttab,\r\n* Table\u00a0of\u00a0inactive\u00a0CUA\u00a0functions\u00a0for\u00a0view\u00a0maintenance\r\n       BEGIN\u00a0OF\u00a0excl_cua_funct\u00a0OCCURS\u00a01.\r\n         INCLUDE\u00a0STRUCTURE\u00a0vimexclfun.\r\n DATA:\u00a0END\u00a0OF\u00a0excl_cua_funct.\r\n DATA:\u00a0lt_enq_del\u00a0TYPE\u00a0STANDARD\u00a0TABLE\u00a0OF\u00a0seqg3,\r\n       lt_enq_read\u00a0TYPE\u00a0STANDARD\u00a0TABLE\u00a0OF\u00a0seqg7,\r\n       lw_enq_read\u00a0TYPE\u00a0seqg7,\r\n       lw_enq_del\u00a0TYPE\u00a0seqg3,\r\n       lv_subrc\u00a0TYPE\u00a0sy-subrc.\r\n*Read\u00a0all\u00a0the\u00a0lock\u00a0details\u00a0in\u00a0system\r\n CALL\u00a0FUNCTION\u00a0'ENQUE_READ2'\r\n   EXPORTING\r\n     gclient\u00a0=\u00a0sy-mandt\r\n     gname\u00a0\u00a0\u00a0=\u00a0'\u00a0'\r\n     guname\u00a0\u00a0=\u00a0'*'\r\n   TABLES\r\n     enq\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0lt_enq_read.\r\n* Search\u00a0entry\u00a0for table-level\u00a0lock\u00a0for\u00a0our\u00a0table\r\n LOOP\u00a0AT\u00a0lt_enq_read\u00a0INTO\u00a0lw_enq_read\r\n   WHERE\u00a0gname\u00a0EQ\u00a0'RSTABLE'\r\n   AND\u00a0\u00a0\u00a0garg\u00a0CS\u00a0'ZROWLOCK'.\r\n   MOVE-CORRESPONDING\u00a0lw_enq_read\u00a0TO\u00a0lw_enq_del.\r\n   APPEND\u00a0lw_enq_del\u00a0TO\u00a0lt_enq_del.\r\n ENDLOOP.\r\n*Delete\u00a0table\u00a0level\u00a0lock\u00a0entry\u00a0for\u00a0our\u00a0table\r\n CALL\u00a0FUNCTION\u00a0'ENQUE_DELETE'\r\n   EXPORTING\r\n     check_upd_requests\u00a0=\u00a01\r\n   IMPORTING\r\n     subrc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0lv_subrc\r\n   TABLES\r\n     enq\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0lt_enq_del.\r\n*Now\u00a0call\u00a0the\u00a0table\u00a0maintenace\u00a0generator.\r\n CALL\u00a0FUNCTION\u00a0'VIEW_MAINTENANCE_CALL'\r\n   EXPORTING\r\n     action\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0'U'\r\n     view_name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0'ZROWLOCK'\r\n     show_selection_popup\u00a0=\u00a0'X'\r\n   TABLES\r\n     dba_sellist\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0selekttab\r\n     excl_cua_funct\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0excl_cua_funct.<\/pre>\n<p>Go to SE93 and create new transaction for report ZREP_ROWLOCK<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"335\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=335\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06.png\" data-orig-size=\"519,369\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Transaction creation\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06.png\" class=\"size-full wp-image-335 alignleft\" alt=\"Transaction creation\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06.png\" width=\"519\" height=\"369\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06.png 519w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06-300x213.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock06-421x300.png 421w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"334\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=334\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07.png\" data-orig-size=\"471,554\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Transaction creation 2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07.png\" class=\"size-full wp-image-334 alignnone\" alt=\"Transaction creation 2\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07.png\" width=\"471\" height=\"554\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07.png 471w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock07-255x300.png 255w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><\/a><\/p>\n<h1>Modify the table maintenance<\/h1>\n<p>We have to modify the maintenance screen and its code so it locks only rows the user selected to be edited.<br \/>\nRun TCode SE80 and open function group ZROWLOCK and open the one step\/single screen you created using table maintenance generator.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"333\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=333\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08.png\" data-orig-size=\"425,361\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Modify table maintenance code\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08.png\" class=\"size-full wp-image-333 alignnone\" alt=\"Modify table maintenance code\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08.png\" width=\"425\" height=\"361\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08.png 425w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08-300x254.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock08-353x300.png 353w\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" \/><\/a><\/p>\n<p>Now we add line with new module.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock09.png\"><img decoding=\"async\" data-attachment-id=\"332\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=332\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock09.png\" data-orig-size=\"\" data-comments-opened=\"1\" data-image-meta=\"[]\" data-image-title=\"New module in table maintenance\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock09.png\" class=\"size-full wp-image-332 alignnone\" alt=\"New module in table maintenance\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock09.png\" \/><\/a><\/p>\n<p>The code inside this module will be as the following<\/p>\n<pre lang=\"abap\">MODULE\u00a0change_locking\u00a0OUTPUT.\r\n*Call\u00a0the\u00a0function\u00a0module\u00a0corresponding\u00a0to\u00a0the\u00a0lock\u00a0object\u00a0we\u00a0created\r\n\u00a0\u00a0CALL\u00a0FUNCTION\u00a0'ENQUEUE_EZROWLOCK'\r\n\u00a0\u00a0\u00a0\u00a0EXPORTING\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0matnr\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0zrowlock-matnr\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0werks\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0zrowlock-werks\r\n\u00a0\u00a0\u00a0\u00a0EXCEPTIONS\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0foreign_lock\u00a0\u00a0\u00a0=\u00a01\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0system_failure\u00a0=\u00a02\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OTHERS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a03.\r\n\u00a0\u00a0IF\u00a0sy-subrc\u00a0NE\u00a00.\r\n*\u00a0row\u00a0is\u00a0locked..hence\u00a0gray..\r\n\u00a0\u00a0\u00a0\u00a0LOOP\u00a0AT\u00a0SCREEN.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0screen-input\u00a0=\u00a00.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MODIFY\u00a0SCREEN.\r\n\u00a0\u00a0\u00a0\u00a0ENDLOOP.\r\n\u00a0\u00a0ENDIF.\r\nENDMODULE.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"\u00a0change_locking\u00a0\u00a0OUTPUT<\/pre>\n<p><span style=\"color: #000000; font-weight: bold;\">Testing<\/span><\/p>\n<p>Now we are ready for testing. Call the transaction ZROWLOCK create some entries with random values in table. Since we have not maintained any check tables etc, the entered values may be invalid, but in a real scenario maintaining check tables should definitely be considered to be implemented.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"331\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=331\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10.png\" data-orig-size=\"402,246\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Sample data creation\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10.png\" class=\"size-full wp-image-331 alignnone\" alt=\"Sample data creation\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10.png\" width=\"402\" height=\"246\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10.png 402w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock10-300x183.png 300w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/a><\/p>\n<p>Save the changes and leave the transaction.<\/p>\n<p>Now open a new session and in both sessions run TCode ZROWLOCK.<\/p>\n<h2>Session 1<\/h2>\n<p>In this we will try to open some existing values for table maintenance.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"330\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=330\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11.png\" data-orig-size=\"425,259\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Session 1 selection\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11.png\" class=\"size-full wp-image-330 alignnone\" alt=\"Session 1 selection\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11.png\" width=\"425\" height=\"259\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11.png 425w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock11-300x182.png 300w\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" \/><\/a><\/p>\n<p>Note\u00a0all selected entries are opened in change mode.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"328\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=328\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13.png\" data-orig-size=\"589,150\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Session 1 &amp;#8211; edit mode\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13.png\" class=\"size-full wp-image-328 alignnone\" alt=\"Session 1 - edit mode\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13.png\" width=\"589\" height=\"150\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13.png 589w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13-300x76.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock13-500x127.png 500w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a><\/p>\n<h2>Session 2<\/h2>\n<p>In \u00a0this session pass a range of materials including the one opened in Session 1.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"329\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=329\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12.png\" data-orig-size=\"421,258\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Session 2 &amp;#8211; selection screen\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12.png\" class=\"size-full wp-image-329 alignnone\" alt=\"Session 2 - selection screen\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12.png\" width=\"421\" height=\"258\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12.png 421w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock12-300x183.png 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/a><\/p>\n<p>On the following you can see the row opened previously in Session 1 in edit mode is now disabled for editing. But the remaining rows are all enabled and locked for the current user\/session.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"327\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=327\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14.png\" data-orig-size=\"605,268\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Session 2 &amp;#8211; edit mode\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14.png\" class=\"size-full wp-image-327 alignnone\" alt=\"Session 2 - edit mode\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14.png\" width=\"605\" height=\"268\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14.png 605w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14-300x132.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/row_lock14-500x221.png 500w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default behavior is if a person opens table maintenance generator and tries to maintain the table, the table is locked and no one else can maintain the same table at the same time. This is because there is a &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=322\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,9],"tags":[446,70,78,17,30],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","tag-abap","tag-database","tag-lock","tag-sap","tag-table"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-5c","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322"}],"version-history":[{"count":8,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":363,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions\/363"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}