访问 RFC 调用系统的堆栈内存 [英] Accessing stack memory of RFC-called system

查看:25
本文介绍了访问 RFC 调用系统的堆栈内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当程序在 SAP ECC 中运行时,系统堆栈"存储所有全局变量,而不管在该单个会话中调用了哪些模块/程序.

当它调用支持 RFC 的功能模块 (FM) 时,会在被调用系统中创建一个新的系统堆栈,并且只有在被调用 FM 中定义的导出参数才能在被调用 FM 完成后在 ECC 中检索.

有没有办法在 ABAP 中访问另一个系统堆栈的全局变量?

例如,就我而言:

  • ECC 系统中的 FM BAPI_MATERIAL_AVAILABILITY 通过 RFC 调用 APO 系统中的 FM BAPI_APOATP_CHECK.
  • 当 APO FM 完成时,除了 APO RFC 功能模块中定义的参数之外,我还想访问 APO 系统堆栈的一些全局变量.我需要访问 ECC 系统中的 GTC 对象引用.

PS:通常我们使用下面的 ABAP 语句从同一个堆栈访问内存,但是当内存在另一个系统中时它不起作用:

ASSIGN '(PrgmName)Globalvariable' TO FIELD-SYMBOLS().

解决方案

由于调用后不会自动关闭 RFC 连接,因此会保留用户会话的内存,在此调用之后,您可以调用自定义 RFC-启用的功能模块,您在 APO 系统中创建,访问您希望的内存并返回其值.请注意,不能通过 RFC 传递对象引用.

为了让您更好地理解,我改编了

图例(箭头1"和2"):

  1. 在第一次 RFC 调用时,会打开一个连接,创建一个新的用户会话、ABAP 会话和内部会话.全局变量存储在内部会话中名为(数据)对象"的块中.在调用结束时,连接被保留,包括第一个内部会话及其全局变量.
  2. 在使用相同连接的下一次 RFC 调用(现有连接被重用)时,用户会话被重用(连同其 ABAP 和内部会话)来执行功能模块,因此它可能访问前一个的全局变量电话.

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>).

解决方案

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:

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).

这篇关于访问 RFC 调用系统的堆栈内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆