<?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: how to avoid a function module runnning parallely twice in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589912#M592894</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &amp;lt;b&amp;gt;Jonathan Coleman&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Uwe Schieferstein&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;Uwe&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;, thanks for providing the essential basic approach to this issue, which was very useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;Jonathan&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;, thanks for your elaborate suggestion, which ultimately lead to solving the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Best Regards,&lt;/P&gt;&lt;P&gt;             Adarsh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Aug 2007 11:18:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-07T11:18:53Z</dc:date>
    <item>
      <title>how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589908#M592890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;          There is a scenario, where user calls a function module via RFC.&lt;/P&gt;&lt;P&gt; The requirement is to avoid the user from running the function module parallely twice or more because it may lead to dead lock problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         To realize this creation of a new enqueue object and set up of enqueue of this object in the function is suggested.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        If the object is blocked (which means the function is already being &lt;/P&gt;&lt;P&gt;running by the sorter), it should go out of the function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       Can i get help in locking this function module during execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; With Best Regards,&lt;/P&gt;&lt;P&gt;           Adarsh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2007 14:54:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589908#M592890</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-06T14:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589909#M592891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Adarsh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the RFC calls all come from the same system (= calling system) then I would recommend to create a simple "lock structure" containing only a single field for the function module name.&lt;/P&gt;&lt;P&gt;Use this structure to create a lock object. The lock entry simply contains the called function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your program could contain the following logic (pseudo coding):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  IF ( &amp;lt;lock entry for function module exists already&amp;gt; ).
    MESSAGE 'No parallel processing of fm ...'  TYPE 'S'.

  ELSE.
    CALL FUNCTION '&amp;lt;enqueue function module&amp;gt;'  " set lock
      EXPORTING
        funcname = '&amp;lt;name of function module'
        ... .

     IF ( syst-subrc = 0 ).  " lock could be set
       CALL FUNCTION '&amp;lt;name of function module&amp;gt;
         DESTINATION '&amp;lt;rfc destination&amp;gt;'
         ... .

    CALL FUNCTION '&amp;lt;dequeue function module&amp;gt;'  " remove lock
      EXPORTING
        funcname = '&amp;lt;name of function module'
        ... .   

     ELSE.
       " error message in case of lock failure
     ENDIF.

  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the lock has to be user specific simply add a username field to your lock structure.&lt;/P&gt;&lt;P&gt;If the RFC-enabled function module can be called from different systems then you could place the locking logic into the called function module. Obviously, the locking structure must then be created on the remote system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2007 20:15:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589909#M592891</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-08-06T20:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589910#M592892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Uwe,&lt;/P&gt;&lt;P&gt;           Thanks for your reply. The RFC-enabled function module can be called from different systems, so as suggested by you the locking logic could be placed into the called function module.&lt;/P&gt;&lt;P&gt;           But I don't have access or to the calling remote system, to create a locking structure on it.&lt;/P&gt;&lt;P&gt;           And I also need help in creating the locking structure, as I have not created any such locking structure before.&lt;/P&gt;&lt;P&gt;           Can u brief me further on this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Best Regards,&lt;/P&gt;&lt;P&gt;         Adarsh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 05:20:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589910#M592892</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T05:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589911#M592893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a sample of how you might do this - see comments in code for explanation.. run the program in two differ SAPGui sessions to see the effect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zlocal_jc_tfdir_lock.
                                                                       
start-of-selection.                                                    
  perform set_and_check_lock.                                                                                
form set_and_check_lock.                                               
*" Use SAP enqueue to prevent multiple RFC calls of same object        
  data:                                                                
    l_object             like tfdir-funcname.                                                                                
*" Build some name that is specific to your needs                      
*" Include sy-uname in key if lock is per user, not for process                                                                                
concatenate '#Z LOCK:' sy-uname into l_object.                       
*" and enqueue                                                         
  call function 'ENQUEUE_ESFUNCTION'                                   
       exporting                                                       
            funcname       = l_object                                  
       exceptions                                                      
            foreign_lock   = 1                                         
            system_failure = 2                                         
            others         = 3.                                                                                
if not sy-subrc is initial.                                          
    message e398(00)                                                   
      with                                                        
        l_object 'is held by' sy-msgv1 space.                     
  else.                                                           
    write: / l_object, 'is now locked - check sm12 for proof'.    
  endif.                                                                                
endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 06:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589911#M592893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T06:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589912#M592894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &amp;lt;b&amp;gt;Jonathan Coleman&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Uwe Schieferstein&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;Uwe&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;, thanks for providing the essential basic approach to this issue, which was very useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;Jonathan&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;, thanks for your elaborate suggestion, which ultimately lead to solving the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Best Regards,&lt;/P&gt;&lt;P&gt;             Adarsh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 11:18:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589912#M592894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T11:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589913#M592895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jonathan and Uwe.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 11:22:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589913#M592895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T11:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to avoid a function module runnning parallely twice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589914#M592896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank u for the information&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2007 11:52:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-a-function-module-runnning-parallely-twice/m-p/2589914#M592896</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-13T11:52:32Z</dc:date>
    </item>
  </channel>
</rss>

