<?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: SPBT_INITIALIZE - pbt_env_already_initialized error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271797#M1530237</link>
    <description>&lt;P&gt;I had a problem where it was throwing me this exception when calling the SPBT_INITIALIZE in the same session one after another. The second time I would get the exception and I was not sure I should let the processing continue. And the thing is you should not let processing continue if you don't have the number of free process works. But you could find those with help of function module 'SPBT_GET_CURR_RESOURCE_INFO'.&lt;BR /&gt;So now I have:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SPBT_INITIALIZE'
      EXPORTING
        group_name                     = lv_rfcgr
      IMPORTING
        free_pbt_wps                   = lv_free_pbt_wps
      EXCEPTIONS
        invalid_group_name             = 1
        internal_error                 = 2
        pbt_env_already_initialized    = 3
        currently_no_resources_avail   = 4
        no_pbt_resources_found         = 5
        cant_init_different_pbt_groups = 6
        OTHERS                         = 7.
    IF sy-subrc NE 0.
      CASE sy-subrc.
        WHEN 1 or 2 or 4 or 5 or 6 or 7.
          lv_continue_after_exception = abap_false.
        WHEN 3.
          CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO' "try to get free work processes
            IMPORTING
              free_pbt_wps                = lv_free_pbt_wps
            EXCEPTIONS
              internal_error              = 1
              pbt_env_not_initialized_yet = 2
              OTHERS                      = 3.
          IF sy-subrc &amp;lt;&amp;gt; 0.
            lv_continue_after_exception = abap_false.
          ELSE.
            lv_continue_after_exception = abap_true. 
          ENDIF.
      ENDCASE.
    ENDIF.
&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Feb 2022 12:49:33 GMT</pubDate>
    <dc:creator>marius_gabriel_cocis</dc:creator>
    <dc:date>2022-02-18T12:49:33Z</dc:date>
    <item>
      <title>SPBT_INITIALIZE - pbt_env_already_initialized error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271793#M1530233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I do parallel processing in a function module. The report who calls this module works fine. But if I call the module from another module then the first time it works fine but second time I got an pbt_env_already_initialized error from SPBT_INITIALIZE.&lt;/P&gt;&lt;P&gt;How can I solve this? Can I check whether it's already initialized before doing SPBT_INITIALIZE? Or should I close something at the end?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;P&gt;Susanne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Sep 2010 12:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271793#M1530233</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-08T12:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: SPBT_INITIALIZE - pbt_env_already_initialized error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271794#M1530234</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 error, &lt;STRONG&gt;pbt_env_already_initialized error&lt;/STRONG&gt;  denotes that Function module may be called only once &amp;amp; is called automatically by R/3 if you do not call before starting parallel processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be because of Programming error &amp;amp; just ckeck &amp;amp; see where in program the error is coming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Abhii&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Sep 2010 12:58:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271794#M1530234</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-08T12:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: SPBT_INITIALIZE - pbt_env_already_initialized error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271795#M1530235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Susanne,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pbt_env_already_initialized is an exception. You only have to handle it in your program. First check if your program is calling the FM multiple times. Secondly, check if there is any other program using the same server group that has called the FM before your program did.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If everything else looks good, you can try ignoring the exception. See below example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CALL FUNCTION 'SPBT_INITIALIZE'                   
       EXPORTING                                    
            group_name                   = p_group  
       IMPORTING                                    
            max_pbt_wps                  = max_wps  
            free_pbt_wps                 = free_wps 
       EXCEPTIONS                                   
            invalid_group_name           = 1        
            internal_error               = 2        
            pbt_env_already_initialized  = 3        
            currently_no_resources_avail = 4        
            no_pbt_resources_found       = 5        
            OTHERS                       = 6.       

    CASE sy-subrc.
      WHEN 0.
      WHEN 1.
        WRITE: / 'No server group defined for'(023), p_group.
        EXIT.
      WHEN 2.
        WRITE / 'Internal Error when initializing server group.'(024).
        EXIT.
      WHEN 3.
        WRITE: / 'PBT environment was already initialized for group.'(025).
*       Let us proceed and see what happens
      WHEN OTHERS.
*       Do whatever is needed
    ENDCASE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Sep 2010 14:51:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271795#M1530235</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-08T14:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: SPBT_INITIALIZE - pbt_env_already_initialized error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271796#M1530236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the answers. Cause I couldn't find a method who checks whether the server group is already initialized I use now a global flag to avoid starting twice.&lt;/P&gt;&lt;P&gt;Susanne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 05:31:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271796#M1530236</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-14T05:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: SPBT_INITIALIZE - pbt_env_already_initialized error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271797#M1530237</link>
      <description>&lt;P&gt;I had a problem where it was throwing me this exception when calling the SPBT_INITIALIZE in the same session one after another. The second time I would get the exception and I was not sure I should let the processing continue. And the thing is you should not let processing continue if you don't have the number of free process works. But you could find those with help of function module 'SPBT_GET_CURR_RESOURCE_INFO'.&lt;BR /&gt;So now I have:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SPBT_INITIALIZE'
      EXPORTING
        group_name                     = lv_rfcgr
      IMPORTING
        free_pbt_wps                   = lv_free_pbt_wps
      EXCEPTIONS
        invalid_group_name             = 1
        internal_error                 = 2
        pbt_env_already_initialized    = 3
        currently_no_resources_avail   = 4
        no_pbt_resources_found         = 5
        cant_init_different_pbt_groups = 6
        OTHERS                         = 7.
    IF sy-subrc NE 0.
      CASE sy-subrc.
        WHEN 1 or 2 or 4 or 5 or 6 or 7.
          lv_continue_after_exception = abap_false.
        WHEN 3.
          CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO' "try to get free work processes
            IMPORTING
              free_pbt_wps                = lv_free_pbt_wps
            EXCEPTIONS
              internal_error              = 1
              pbt_env_not_initialized_yet = 2
              OTHERS                      = 3.
          IF sy-subrc &amp;lt;&amp;gt; 0.
            lv_continue_after_exception = abap_false.
          ELSE.
            lv_continue_after_exception = abap_true. 
          ENDIF.
      ENDCASE.
    ENDIF.
&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 12:49:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/spbt-initialize-pbt-env-already-initialized-error/m-p/7271797#M1530237</guid>
      <dc:creator>marius_gabriel_cocis</dc:creator>
      <dc:date>2022-02-18T12:49:33Z</dc:date>
    </item>
  </channel>
</rss>

