Skip to Content

call transaction in new session (but only one)

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Posted on Dec 30, 2004 at 11:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Dec 30, 2004 at 10:19 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Just a thought here, if you see <b>SM04</b> transaction, it shows a list of users. If you click on a particular user, and then click on the button <b>Sessions</b>, it shows the list of sessions available. You can end a particular session as well. There is a <b>Delete</b> button available to end a session.

      On debugging the above program, (the code is almost non-understandable), I found that it is doing some system calls and fetching the list of transactions for a given user and while displaying has a structure called <b>MODUS</b>. However I am not sure what is the internal table where it stores this data. As I said, code is a little tricky.

      Let us know if you did this in any other manner.

      Regards,

      Subramanian V.

  • Posted on Dec 30, 2004 at 09:03 PM

    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.
    

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Srinivas Adavi

      Thanks Srinivas. It is a vital piece of information that you have shared. Thankyou very much.

      Regards,

      Subramanian V.

      P.S. Wish you a very Happy New Year

  • author's profile photo
    Former Member
    Posted on Jan 03, 2005 at 01:32 PM

    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 comment
    10|10000 characters needed characters exceeded