2

When a program is running in SAP ECC, the "system stack" stores all global variable irrespective of what modules/programs are called in that single session.

When it's calling RFC-enabled Function Modules (FM), a new system stack is created in the called system and only the export parameters defined in the called FM can be retrieved in ECC when the called FM has finished.

Is there a way to access another system stack's global variables in ABAP?

For example, in my case:

  • The FM BAPI_MATERIAL_AVAILABILITY in the ECC system calls via RFC the FM BAPI_APOATP_CHECK in the APO system.
  • When the APO FM finishes, I want to access some global variables of the APO system stack apart from the parameters defined in the APO RFC Function module. I need to access GTC object reference in ECC system.

PS: normally we use below ABAP statement to access memory from same stack, but it doesn't work when the memory is in another system:

ASSIGN '(PrgmName)Globalvariable' TO FIELD-SYMBOLS(<lo_data>).
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Side note about `ASSIGN '(PrgmName)Globalvariable' TO FIELD-SYMBOLS().`: it's [**for internal use only**](https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abapassign_mem_area_dynamic_dobj.htm#!abap_alternative_1@1@) ; the best workaround is to use the [Enhancement Framework](https://help.sap.com/viewer/search?q=%22Enhancement%20framework%22&language=en-US&product=SAP_NETWEAVER_750). – Sandra Rossi Jul 28 '19 at 05:14

1 Answers1

4

As the RFC connection is not automatically closed after the call, the memory of the user session is retained, right after this call, so you may call a custom RFC-enabled function module that you create in the APO system, that accesses the memory you wish and return its value. Note that an object reference cannot be passed via RFC.

So that you better understand, I adapted the official figure about memory areas to show how a RFC call reuses the memory when the connection is not closed between 2 ABAP systems:

Memory Areas within RFC client and server ABAP systems

Legend (arrows "1" and "2"):

  1. At the first RFC call, a connection is opened, a new User Session is created, ABAP session and internal session. The global variables are stored in the block entitled "(Data) Object" inside the internal session. At the end of the call, the connection is retained, including the first internal session and its global variables.
  2. At the next RFC call using the same connection (the existing connection is reused), the user session is reused (along with its ABAP and internal sessions) to execute the function module, consequently it may access the global variables of the previous call(s).
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48