Skip to Content

CALL FM in new context

Hi, all.

Is there a possibilty to call a FM in order to have its own context.
I want to call a FM in the same FG but I dont want to keep the global data.

I've tried with STARTING NEW TASK but its being executed in background. And I want to display some screens within my FM.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 04, 2017 at 05:38 PM

    Why do you say that executing the function module in "background" (that's not exactly true as it's simply asynchronous RFC aka aRFC) is a problem, as you display a dialog too, asynchronously? Did you try?

    You may also do it synchronously using CALL FUNCTION 'XXXX' DESTINATION 'NONE'. It will start a new user session. Dialogs are allowed in this mode, but the calling session is waiting for it to be finished (so the calling screen is inoperant). Be aware that the second time you call it, it will reuse the same memory context except if you have explicitly closed the connection after the CALL FUNCTION (using function module RFC_CONNECTION_CLOSE).

    Add comment
    10|10000 characters needed characters exceeded

    • Hi, Sandra.

      Thanks for the clarification about "background" and asynchronous.

      Yes, I think it's working fine with DESTINATION 'NONE' and closing the connection afterwards.


  • May 04, 2017 at 03:54 PM


    one of the differences between class OO approach and function group is the answer to your question.

    Use class/methods and global public attributes to have what you're looking for. Every instance will have its context.

    Hope to help


    Add comment
    10|10000 characters needed characters exceeded

    • mmm, yes...

      But, to display the screens I need a FG.

      This is the scenario; I have a big FG with a lot of screens and data. My FM Z1 displays the screens with all these tabs and data. One of the tabs have a version table. If I click one of these versions I need to call again my FM Z1 to display this version. But I want to return to my previous displayed version, and it's a mess with all these global data... As a workaround I've create a report to call the FM and I'm doing a submit, it is working fine, but I wonder if there is other way to do it.

      Let me think... In case use OO, If I want to display a version I need to create a new instance of my object and call the method that calls the FM Z1, don't I? In this scenario is a different context? because the caller is the same, isn't it?