2010 Sep 08 1:35 PM
Hi,
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.
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?
Thanks and regards
Susanne
2010 Sep 08 3:51 PM
Susanne,
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.
If everything else looks good, you can try ignoring the exception. See below example.
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.
Hi,
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.
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?
Thanks and regards
Susanne
2010 Sep 08 1:58 PM
Hi
The error, pbt_env_already_initialized error denotes that Function module may be called only once & is called automatically by R/3 if you do not call before starting parallel processing.
This could be because of Programming error & just ckeck & see where in program the error is coming.
Regards
Abhii
2010 Sep 08 3:51 PM
Susanne,
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.
If everything else looks good, you can try ignoring the exception. See below example.
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.
2010 Sep 14 6:31 AM
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.
Susanne
2022 Feb 18 12:49 PM
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'.
So now I have:
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 <> 0.
lv_continue_after_exception = abap_false.
ELSE.
lv_continue_after_exception = abap_true.
ENDIF.
ENDCASE.
ENDIF.
<br>
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |