<?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: lock objects for a transaction in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565713#M1269780</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the only possible way to lock a tcode . accordingg to my research is to use TSTC table while creating enqueue and dequeue FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i found success in my research.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thankyou for sharing.&lt;/P&gt;&lt;P&gt;kat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 May 2009 11:03:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-14T11:03:03Z</dc:date>
    <item>
      <title>lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565708#M1269775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i know this is a general question, but this isn't working in my system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i would like to apply lock to a custom transaction. for this i applied a lock to a custom table which i'm reading and writing and the type i used is &lt;STRONG&gt;exclusive lock&lt;/STRONG&gt;.  when i logged the tcode with another user i executed both , then the tcode worked with both the users simultanious. i believe am i missing any thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;scenario to be done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at a time only one session should be opened for one user only i.e. if the another user or same user opens another session it should give error &lt;STRONG&gt;'table has been locked or t code is locked'&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please suggest which type do i use and where do i apply. i used enqueue at start of dialog program and dequeue at exit of the dialog program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;kat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: kat k on May 13, 2009 1:31 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 11:31:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565708#M1269775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T11:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565709#M1269776</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;if you want to get the error table has been loacked you need to create a lock object for the tables used in the Custom transaction...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you need to lock the tables when ever you are editing..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and second way is..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want to lock the t-code ..&lt;/P&gt;&lt;P&gt;use the Below function modules...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 " Locking the transaction in SM01
    PERFORM bit-set USING tstc-cinfo 6.
    CALL FUNCTION 'RSAU_WRITE_SM01_LOG'
      EXPORTING
        tcode = tstc-tcode            "Enter custom t-code to unlock
        lock  = 'X'.
    IF sy-subrc &amp;lt;&amp;gt; 0.
    ENDIF.

"  UNLocking the transaction in SM01
    PERFORM bit-reset USING tstc-cinfo 6.
    CALL FUNCTION 'RSAU_WRITE_SM01_LOG'
      EXPORTING
        tcode  = tstc-tcode             "Enter custom t-code to Lock
        unlock = 'X'.
    IF sy-subrc &amp;lt;&amp;gt; 0.
    ENDIF.


FORM bit-set USING hexval TYPE x
                   bitpos TYPE p.
  CASE bitpos.
    WHEN 8. IF hexval O x80. ELSE. hexval = hexval + x80. ENDIF.
    WHEN 7. IF hexval O x40. ELSE. hexval = hexval + x40. ENDIF.
    WHEN 6. IF hexval O x20. ELSE. hexval = hexval + x20. ENDIF.
    WHEN 5. IF hexval O x10. ELSE. hexval = hexval + x10. ENDIF.
    WHEN 4. IF hexval O x08. ELSE. hexval = hexval + x08. ENDIF.
    WHEN 3. IF hexval O x04. ELSE. hexval = hexval + x04. ENDIF.
    WHEN 2. IF hexval O x02. ELSE. hexval = hexval + x02. ENDIF.
    WHEN 1. IF hexval O x01. ELSE. hexval = hexval + x01. ENDIF.
    WHEN OTHERS.
  ENDCASE.
ENDFORM.                    "bit-set

FORM bit-reset USING xval TYPE x
                     pos  TYPE p.
  CASE pos.
    WHEN 8. IF xval O x80. xval = xval - x80. ENDIF.
    WHEN 7. IF xval O x40. xval = xval - x40. ENDIF.
    WHEN 6. IF xval O x20. xval = xval - x20. ENDIF.
    WHEN 5. IF xval O x10. xval = xval - x10. ENDIF.
    WHEN 4. IF xval O x08. xval = xval - x08. ENDIF.
    WHEN 3. IF xval O x04. xval = xval - x04. ENDIF.
    WHEN 2. IF xval O x02. xval = xval - x02. ENDIF.
    WHEN 1. IF xval O x01. xval = xval - x01. ENDIF.
    WHEN OTHERS.
  ENDCASE.
ENDFORM.                    "bit-reset

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Prabhu Das on May 13, 2009 5:09 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 11:39:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565709#M1269776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T11:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565710#M1269777</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;Here is an example on the Table : VTTK (Shipment number), where, assume we create a Lock object on the field TKNUM (Shipment Number).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our aim is, at one time, no two persons can open a Shipment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the code goes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'ENQUEUE_EYVTTKTKNUM'
           EXPORTING
                mode_vttk      = 'E'
                mandt          = sy-mandt
                tknum          = v_tknum
                _scope         = '2'
                _wait          = ' '
                _collect       = ' '
           EXCEPTIONS
                foreign_lock   = 1
                system_failure = 2
                OTHERS         = 3.

* Getting the UserId of the Locked Transport Number

      wg_lock_user = sy-msgv1.

Also Note that the system variable, sy-msgv1 will have the &amp;lt;User name&amp;gt;.  
We can even display the UserName also dynamically.

Based on teh above SY-SUBRC, we can give Error Message for restricting another user from using this Shipment Number.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Ramani N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ramani Nagarajan on May 13, 2009 1:41 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 11:41:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565710#M1269777</guid>
      <dc:creator>former_member229729</dc:creator>
      <dc:date>2009-05-13T11:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565711#M1269778</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;Make a COMMIT WORK after adding a lock to the customer table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 11:43:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565711#M1269778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T11:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565712#M1269779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi prabu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i really don't understand , is it really necessary to fill hex val in perform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please expalin logic in perform. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!!&lt;/P&gt;&lt;P&gt;kat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2009 12:46:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565712#M1269779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-13T12:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: lock objects for a transaction</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565713#M1269780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the only possible way to lock a tcode . accordingg to my research is to use TSTC table while creating enqueue and dequeue FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i found success in my research.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thankyou for sharing.&lt;/P&gt;&lt;P&gt;kat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 11:03:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/lock-objects-for-a-transaction/m-p/5565713#M1269780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T11:03:03Z</dc:date>
    </item>
  </channel>
</rss>

