<?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: Loop for locking issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986463#M1341677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI  Prashant Patil    	 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can u explain the logic please ,&lt;/P&gt;&lt;P&gt;1. why u choose to wait one sec .&lt;/P&gt;&lt;P&gt;2.  why u  Update custom table&lt;/P&gt;&lt;P&gt;3. the looping reason&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks ,&lt;/P&gt;&lt;P&gt;Joy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Aug 2009 19:30:31 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-12T19:30:31Z</dc:date>
    <item>
      <title>Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986461#M1341675</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;i have to delete entries from Z table and i want to verify 2 things :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.  if the entry is update by another program do i need to use the lock concept ?&lt;/P&gt;&lt;P&gt;2. if the entry updated by user when i want to lock the entry i want to do loop and wait &lt;/P&gt;&lt;P&gt;until the table released by user ,my question is how much time i need to do that .&lt;/P&gt;&lt;P&gt;there is any sap program that do the looping on the locked table until it resaled  ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Joy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 08:49:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986461#M1341675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-12T08:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986462#M1341676</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;Yes u have to lock the table before update, refer following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Check if monitor table is initial&lt;/P&gt;&lt;P&gt;  IF NOT gt_hdrlog[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT gt_hdrlog INTO ls_monitor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Lock the DB table ZAPT_AR_MONITOR before updation&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'ENQUEUE_EZAPT_AR_MONITOR'&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          mode_zapt_ar_monitor = lc_x                 "Check&lt;/P&gt;&lt;P&gt;          mandt                = sy-mandt             "Cient&lt;/P&gt;&lt;P&gt;          doc_num              = ls_monitor-doc_num   "IDOC number&lt;/P&gt;&lt;P&gt;          x_doc_num            = lc_x                 "Check&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 NE 0.&lt;/P&gt;&lt;P&gt;        WAIT UP TO 1 SECONDS.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;*--If DB table is locked then insert data into custom table&lt;/P&gt;&lt;P&gt;        INSERT into zapt_ar_monitor values ls_monitor.&lt;/P&gt;&lt;P&gt;        IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;*--Update custom table&lt;/P&gt;&lt;P&gt;          UPDATE zapt_ar_monitor FROM ls_monitor.&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;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Unlock the table after updation&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'DEQUEUE_EZAPT_AR_MONITOR'&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          mode_zapt_ar_monitor = lc_x                 "Check&lt;/P&gt;&lt;P&gt;          mandt                = sy-mandt             "Client&lt;/P&gt;&lt;P&gt;          doc_num              = ls_monitor-doc_num   "IDOC Number&lt;/P&gt;&lt;P&gt;          x_doc_num            = lc_x.                "Check&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Clear the work areas&lt;/P&gt;&lt;P&gt;      CLEAR : ls_monitor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 08:51:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986462#M1341676</guid>
      <dc:creator>former_member386202</dc:creator>
      <dc:date>2009-08-12T08:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986463#M1341677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI  Prashant Patil    	 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can u explain the logic please ,&lt;/P&gt;&lt;P&gt;1. why u choose to wait one sec .&lt;/P&gt;&lt;P&gt;2.  why u  Update custom table&lt;/P&gt;&lt;P&gt;3. the looping reason&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks ,&lt;/P&gt;&lt;P&gt;Joy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 19:30:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986463#M1341677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-12T19:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986464#M1341678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joy, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other concept would be:&lt;/P&gt;&lt;P&gt;1) in program A export your table with entries to delete to ABAP memory&lt;/P&gt;&lt;P&gt;2) create separate report (B) wherein:&lt;/P&gt;&lt;P&gt;a) import this table back from ABAP memory&lt;/P&gt;&lt;P&gt;b) check if each entry (within loop) is not currently changed by someone else -&amp;gt; for this call locking FM for each entry (key fields must be provided in order to get state of that entry in DB) &lt;/P&gt;&lt;P&gt;c) depending on the result sy-subrc = 0 delete the entry you are currently looped from DB and internal table (you have imported)&lt;/P&gt;&lt;P&gt;d) export all entries to ABAP memory once again, but only those remaining ones (which were locked)&lt;/P&gt;&lt;P&gt;e) if any entries were exported, set JOB using fms JOB_OPEN, JOB_CLOSE for the report which you are currently in &lt;/P&gt;&lt;P&gt;d) in JOB details set it to run only once (if it runs correctly next time it will not create new one, otherwise it will keep creating new jobs trying persistenlty to delete those remaining entires), set it i.e to run in five minutes time&lt;/P&gt;&lt;P&gt;3) submit report B with RETURN option in place where you would normally do deletion (in program A)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just an idea but has to be tested and aligned if needed, but would solve with deleting all the entries by recursive calls which are done periodically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 20:02:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986464#M1341678</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-08-12T20:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986465#M1341679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Marcin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do u have a program that following this procedure ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 20:21:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986465#M1341679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-12T20:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986466#M1341680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunatelly no, I just made it up for you. &lt;/P&gt;&lt;P&gt;I don't know if this is best practise approach but will likely to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe there could be some other (simplier) solution with asynchornous calls which could also solve it, maybe some function module which I am not aware of. But for the moment this was the only thing which came to my mind. You may try it. Don't hesitate to share your doubts if any reached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 20:26:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986466#M1341680</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-08-12T20:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986467#M1341681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Marcin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think its good idea Tomorrow i try to implement it and let u know , &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1. i provide class with method which  always delete one entry per user  ,per specified key &lt;/P&gt;&lt;P&gt;do i need to do loop for that also and export to memory ?&lt;/P&gt;&lt;P&gt;2. i am not using report so what should i change in your flow ?&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;Best Regards&lt;/P&gt;&lt;P&gt;Joy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 20:39:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986467#M1341681</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-12T20:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loop for locking issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986468#M1341682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem Joy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the questions:&lt;/P&gt;&lt;P&gt;1) I think you can do two things:&lt;/P&gt;&lt;P&gt;- either create a method which collects all these entries for deletion and then sends it to the unit which would delete them (preferably program as this only can be run via JOB)&lt;/P&gt;&lt;P&gt;- call your method with specified key and if deletion of that entry fails than do recursive call on that method once again&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
method del_meth.
  delete ....
  if sy-subrc &amp;lt;&amp;gt; 0.
      wait .... "wait can be added, as this unit would execute teens/houndreds of times in one second , so waste of time as entry is probably still locked
      me-&amp;gt;del_meth( ...) "call myself once again with same key
  endif.
endmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...so it would over and over again try deleting this certain entry. This solution however results in occupying work process for all the time it executes so it might dump out the program in case the entry is locked for too long (i.e. if someone went for lunch and meantime is editing some table entry;) )&lt;/P&gt;&lt;P&gt;2) you can still stick to OO approach and just call your program B from a method, once you collected all entries within second method. Please note that sending each entry for deletion in program B would result in separate JOB opening for each locked one, so this could have dramatic influence on system performance. That's why I would recommned to get these data together to some table and then exchange this table with program B. At the end you may RETURN from the program and keep executing your program A. At the same time program B will schedule itself to run again and again if update fails in subsequent runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course these are just my suggestions, you shall do as you feel the best is. Note also that if deleting these entries are crucial for further program A execution, this approach might not be what you are looking for, so we would have to think of alternative solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 21:08:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-for-locking-issue/m-p/5986468#M1341682</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-08-12T21:08:34Z</dc:date>
    </item>
  </channel>
</rss>

