<?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: locking the abap program - is it possible ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753643#M1114924</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; The SAP System Table TRDIR has a field called EDTX which is basically the EDITOR lock filed. Edit Lock facility is given in the PROGRAM ATTRIBUTES. The EDITOR LOCK is a check box given in the PROGRAM ATTRIBUTES. If this field is SET then the program gets locked and if this is Unchecked the the program is unlocked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;A href="http://abaplovers.blogspot.com/2008/06/sap-abap-program-editor-lockunlock.html" target="test_blank"&gt;http://abaplovers.blogspot.com/2008/06/sap-abap-program-editor-lockunlock.html&lt;/A&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Neenu Jose on Oct 30, 2008 5:47 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Neenu Jose on Oct 30, 2008 5:51 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2008 04:47:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-30T04:47:00Z</dc:date>
    <item>
      <title>locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753641#M1114922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any possibility to lock the code to get executed by only one session of ABAP.  Locking the code before select statement till commit. so that when the same program is executed in parallel session will wait to execute this part of the code.&lt;/P&gt;&lt;P&gt;REPORT Z_XYZ&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;SELECT * INTO ls_vbak FROM vbak&lt;/P&gt;&lt;P&gt;                       UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;                       WHERE (lt_where).  &lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF sy-subrc IS INITIAL .&lt;/P&gt;&lt;P&gt;  ....&lt;/P&gt;&lt;P&gt;Else&lt;/P&gt;&lt;P&gt;...&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;Call function Bapi&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Commit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 04:11:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753641#M1114922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T04:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753642#M1114923</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;You cannot lock a program from getting executed in multiple sessions, what i would suggest is you could create a lock on the database table, on which you want to perform the operation. If you take a lock on a db table, only one session/user can use modify that table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lock can be taken on a single record of the database table also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Navneeth K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 04:13:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753642#M1114923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T04:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753643#M1114924</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; The SAP System Table TRDIR has a field called EDTX which is basically the EDITOR lock filed. Edit Lock facility is given in the PROGRAM ATTRIBUTES. The EDITOR LOCK is a check box given in the PROGRAM ATTRIBUTES. If this field is SET then the program gets locked and if this is Unchecked the the program is unlocked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;A href="http://abaplovers.blogspot.com/2008/06/sap-abap-program-editor-lockunlock.html" target="test_blank"&gt;http://abaplovers.blogspot.com/2008/06/sap-abap-program-editor-lockunlock.html&lt;/A&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Neenu Jose on Oct 30, 2008 5:47 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Neenu Jose on Oct 30, 2008 5:51 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 04:47:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753643#M1114924</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T04:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753644#M1114925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4871529"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 04:50:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753644#M1114925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T04:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753645#M1114926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Sam,&lt;/P&gt;&lt;P&gt;You can do it in this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you create a lock object System automatically creat two function module. &lt;/P&gt;&lt;P&gt;1. ENQUEUE_&amp;lt;Lockobject name&amp;gt;. to insert the object in a queue. &lt;/P&gt;&lt;P&gt;2. DEQUEUE_&amp;lt;Lockobject name&amp;gt;. To remove the object is being queued through above FM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chidanand&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 05:13:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753645#M1114926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T05:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753646#M1114927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can we put a lock on select statment of vbak table and &lt;/P&gt;&lt;P&gt;release the lock after commit statment ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that the other session cannot access select of vbak till the sales gets updated in vbak table.  so that when next parallel session selects from vbak table, then it find the entry in vbak and no sales order gets created by parallel session ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please reply earliest because i am in such a need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 13:40:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753646#M1114927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T13:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753647#M1114928</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;Hope the following Threads will help you regarding your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04s/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04s/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nitesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 13:43:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753647#M1114928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T13:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753648#M1114929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam ,&lt;/P&gt;&lt;P&gt;we can do it by using SAP memory (GET, SET)&lt;/P&gt;&lt;P&gt;create a parameter ID&lt;/P&gt;&lt;P&gt;and check the parameter ID at beging of the program and if it is initial pass 'X' to that parameter ID and do u r code&lt;/P&gt;&lt;P&gt;finally clear the value in parameter ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kiran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 13:44:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753648#M1114929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T13:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753649#M1114930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kiran,&lt;/P&gt;&lt;P&gt;Iam not good in SET/GET&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me withclear coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 13:47:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753649#M1114930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T13:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753650#M1114931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let parameter id is 'ZABCD'&lt;/P&gt;&lt;P&gt;data : v_abcd type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET PARAMETER ID 'ZABCD' FIELD v_abcd&lt;/P&gt;&lt;P&gt;if v_abcd is initial.&lt;/P&gt;&lt;P&gt;v_abcd = 'X'.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'ZABCD' FIELD v_abcd&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;--- u r code.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear v_abcd.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'ZABCD' FIELD v_abcd.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 14:13:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753650#M1114931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T14:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753651#M1114932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can lock a program from getting executed more than once at the same time. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All you need to do is put a lock on the program name using the following function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;call function 'ENQUEUE_E_TRDIR'
 exporting
*   MODE_TRDIR           = 'X'
   name                 = sy-repid
*   X_NAME               = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
  EXCEPTIONS
    FOREIGN_LOCK         = 1
    SYSTEM_FAILURE       = 2
    OTHERS               = 3
          .
if sy-subrc  0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then of course call the DEQUEUE when you are done.  If another person runs this program, they will get an error message saying who is currently locking the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 14:18:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753651#M1114932</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2008-10-30T14:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: locking the abap program - is it possible ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753652#M1114933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rich,&lt;/P&gt;&lt;P&gt;you came into picture GREAT. &lt;/P&gt;&lt;P&gt;Thanks for the explation with the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my basic quesion :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is there any way by which we can set up a lock at the file so that it cannot be used by another session if it is already in use by one session?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1).My problem :&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;basically I am in dilema, because my program runs with the file and submits file to another program then 
check vbak table for exixtance of PO# in the file
and if no po is there then this second program submits to third program where Bapi builds sales order data for the PO# in file and 
then commits ...so that the sales order created.

Is there any possibility, that we can lock the file so that another parallel session cannot use the same file till first session completes the execution till commit stmt ?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2). if my program runs in parallel sessions,&lt;/P&gt;&lt;P&gt;will the first session lock the program  with enque ?&lt;/P&gt;&lt;P&gt;is it unlocked automatically after commit stmt ?&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;What about DEQUEUE ? Is it simple same parametes passing into FM except the name of the FM as&lt;/P&gt;&lt;P&gt;call function '&lt;STRONG&gt;D&lt;/STRONG&gt;ENQUEUE_E_TRDIR' ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;==================================&lt;/P&gt;&lt;P&gt;Kiran suggested set parameter ( I don't have much idea )&lt;/P&gt;&lt;P&gt;what parameter id , i can use  ? can I use simply 'ZABCD' ( will it work ?)&lt;/P&gt;&lt;P&gt;I kiran's suggestion works...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can I use this in first program&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;data : v_abcd type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET PARAMETER ID 'ZABCD' FIELD v_abcd&lt;/P&gt;&lt;P&gt;if v_abcd is initial.&lt;/P&gt;&lt;P&gt;v_abcd = 'X'.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'ZABCD' FIELD v_abcd&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u r code. &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and in third program&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;clear v_abcd.&lt;/P&gt;&lt;P&gt;SET PARAMETER ID 'ZABCD' FIELD v_abcd.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 15:07:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/locking-the-abap-program-is-it-possible/m-p/4753652#M1114933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T15:07:21Z</dc:date>
    </item>
  </channel>
</rss>

