Dear all,
as a hotspot functionality I would like to open a new transaction in a new session. For that reason, I use the FM ABAP4_CALL_TRANSACTION with the option STARTING NEW TASK.
However I would like to restrict the new tasks in a way that only one session is used (no matter how often the user clicks the hotspot. Kind of like the ABAP Help in the workbench.
I checked the class CL_IMC_MODE to see if it could work as a new internal session but the new mode dumped when I pressed the back button and according to the dump Statements that closes the internal mode unexpectedly like LEAVE are not allowed. Since I call standard transactions (like VA03) I can hardly prevent that. Did I miss something or do you have any other idea how I could solve my problem?
Thank you for any input.
Christian
Hi Christian
That's a very challenging issue dealing with "CL_IMC_MODE". Synchronous sessions, screen handling, etc... lots of things to understand. Moreover it uses RFC and system calls. Hope you can handle it.
Or you can do what Subramanian suggested. Delete the session opened for the relevant transaction. However, if there are more than one instances of the same transaction it will fail since you would be just knowing the transaction code and you have no guaranteed way to distinguish a session opened by your program's trigger and manually by the user himself, either.
*--Serdar
Hello Christian,
an usage of the Enqueue techinque might solve your technique. But this require setting an accordning lock on side of the new task. As consequence this requires that you use an own (copied & extended) FuBa.
Best Regards
Klaus
Hi Christian,
Here is a sample code that takes in a sales order number, displays the document number as hotspot and when the user clicks on the hotspot, it opens a new window for displaying the order. No matter how many times the user clicks on the hotspot, it will only display one window for VA03. I hope this solves your problem.
REPORT ztest. PARAMETERS: p_vbeln LIKE vbak-vbeln. DATA: ls_vbak LIKE vbak. DATA: BEGIN OF i_rfc_spagpa OCCURS 0. INCLUDE STRUCTURE rfc_spagpa. DATA: END OF i_rfc_spagpa. DATA: v_mode LIKE sy-index. *------------------ START-OF-SELECTION. *------------------ SELECT SINGLE * FROM vbak INTO ls_vbak WHERE vbeln = p_vbeln. IF sy-subrc <> 0. *-- error. ENDIF. WRITE:/ ls_vbak-vbeln HOTSPOT, ls_vbak-vkorg. *----------------- AT LINE-SELECTION. *----------------- CASE sy-ucomm. WHEN 'PICK'. *-- Delete the previous session and then call VA03 in a new session CALL FUNCTION 'TH_DELETE_MODE' EXPORTING mode = v_mode. CLEAR: i_rfc_spagpa, i_rfc_spagpa[]. i_rfc_spagpa-parid = 'AUN'. i_rfc_spagpa-parval = p_vbeln. APPEND i_rfc_spagpa. CLEAR i_rfc_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST' EXPORTING tcode = 'VA03' skip_screen = 'X' mode_val = 'A' update_val = 'A' * IMPORTING * SUBRC = TABLES * USING_TAB = spagpa_tab = i_rfc_spagpa * MESS_TAB = EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 OTHERS = 3 . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. WHEN OTHERS. ENDCASE.
Hello Christian,
what I sometimes do to prevent multiple execution on a pushbutton event is something like this:
<pre>..
clear counter.
import counter from memory id 'counter'.
if counter eq 0.
counter = counter + 1.
export counter to memory id 'counter'.
**
<b>here call the function that should be called only once.</b>
**
free memory id 'counter'.
endif
..</pre>
Regards
Ferdi
Add a comment